Skip to content
Snippets Groups Projects
Commit 62e1f8bf authored by Moreau Elise's avatar Moreau Elise
Browse files

[api][users routes] code typo

parent c1852701
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ const userSchema = Joi.object({
});
// Créer un nouvel utilisateur
router.post('/', validator.body(userSchema), async function(req, res){
router.post('/', validator.body(userSchema), async function(req, res, next){
if (req.body.confirm !== req.body.password){
return res.status(400).json({
......@@ -31,7 +31,7 @@ router.post('/', validator.body(userSchema), async function(req, res){
if(user){
return res.status(409).json({
error: 'Username already exists.'
})
});
}
} catch(err) {
return next(err);
......@@ -50,7 +50,7 @@ router.post('/', validator.body(userSchema), async function(req, res){
}
res.json(newUser);
})
});
const userSchemaLogin = Joi.object({
username: Joi.string().required().trim().min(1),
......@@ -70,7 +70,7 @@ router.post('/login', validator.body(userSchemaLogin), async function(req, res,
if (!user){
return res.status(401).json({
error: 'Fail to authenticate with given credentials.'
})
});
}
const password = crypto.createHash('md5').update(req.body.password).digest("hex");
......@@ -91,7 +91,7 @@ router.post('/login', validator.body(userSchemaLogin), async function(req, res,
}
);
return res.json({token, user: {username: user.username, id: user._id}});
})
});
//Récupérer la liste des utilisateurs
router.get('/', async function (req, res, next){
......@@ -109,6 +109,6 @@ router.get('/', async function (req, res, next){
}
return res.json(users);
})
});
export default router;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment