Implémentation SkydiverId API
This commit is contained in:
+3
-3
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user