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
+3 -3
View File
@@ -7,7 +7,7 @@ const passport = require('passport'),
router.get('/user', auth.required, function (req, res, next) {
User.findById(req.payload.id).then(function (user) {
if (!user) {
return res.sendStatus(401);
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
return res.json({ user: user.toAuthJSON() });
}).catch(next);
@@ -16,7 +16,7 @@ router.get('/user', auth.required, function (req, res, next) {
router.put('/user', auth.required, function (req, res, next) {
User.findById(req.payload.id).then(function (user) {
if (!user) {
return res.sendStatus(401);
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
if (typeof req.body.user.username !== 'undefined') {
user.username = req.body.user.username;
@@ -96,7 +96,7 @@ router.get('/authenticate', function (req, res, next) {
})(req, res, next);
});
router.post('/users', function (req, res, next) {
var user = new User();
let user = new User();
if (typeof req.body.user.username !== 'undefined') {
user.username = req.body.user.username;
} else {