Implémentation SkydiverId API

This commit is contained in:
Rampeur
2024-05-08 20:37:33 +02:00
parent eb64f2c411
commit a4d2b76bc5
43 changed files with 2772 additions and 1267 deletions
+5 -5
View File
@@ -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) });