Implémentation SkydiverId API
This commit is contained in:
@@ -15,7 +15,7 @@ router.param('username', function (req, res, next, username) {
|
||||
}).catch(next);
|
||||
});
|
||||
|
||||
router.get('/:username', auth.optional, function (req, res, next) {
|
||||
router.get('/:username', auth.optional, function (req, res) {
|
||||
if (req.payload) {
|
||||
User.findById(req.payload.id).then(function (user) {
|
||||
if (!user) {
|
||||
@@ -29,11 +29,11 @@ router.get('/:username', auth.optional, function (req, res, next) {
|
||||
});
|
||||
|
||||
router.post('/:username/follow', auth.required, function (req, res, next) {
|
||||
var profileId = req.profile._id;
|
||||
let profileId = req.profile._id;
|
||||
|
||||
User.findById(req.payload.id).then(function (user) {
|
||||
if (!user) {
|
||||
return res.sendStatus(401);
|
||||
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
|
||||
}
|
||||
return user.follow(profileId).then(function () {
|
||||
return res.json({ profile: req.profile.toProfileJSONFor(user) });
|
||||
@@ -42,11 +42,11 @@ router.post('/:username/follow', auth.required, function (req, res, next) {
|
||||
});
|
||||
|
||||
router.delete('/:username/follow', auth.required, function (req, res, next) {
|
||||
var profileId = req.profile._id;
|
||||
let profileId = req.profile._id;
|
||||
|
||||
User.findById(req.payload.id).then(function (user) {
|
||||
if (!user) {
|
||||
return res.sendStatus(401);
|
||||
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
|
||||
}
|
||||
return user.unfollow(profileId).then(function () {
|
||||
return res.json({ profile: req.profile.toProfileJSONFor(user) });
|
||||
|
||||
Reference in New Issue
Block a user