updated
This commit is contained in:
parent
67a37d16ec
commit
c5406006da
8 changed files with 74 additions and 10 deletions
22
backend/service-authentication/changePassword.js
Normal file
22
backend/service-authentication/changePassword.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
const {sendError, sendMessage} = require ("./message");
|
||||
const queries = require('./mongodbQueries');
|
||||
|
||||
async function changePassword (req,res) {
|
||||
if (typeof req.body.username === 'undefined')
|
||||
return sendError(res, 'Vous n\'avez pas envoyé le champ username');
|
||||
|
||||
if (typeof req.body.password === 'undefined')
|
||||
return sendError(res, 'Vous n\'avez pas envoyé le champ password');
|
||||
|
||||
if (typeof req.body.newpassword === 'undefined')
|
||||
return sendError(res, 'Vous n\'avez pas envoyé le champ newpassword');
|
||||
|
||||
const change = await queries.changePasswordQuery(req.body.username, req.body.password, req.body.newpassword);
|
||||
if (change){
|
||||
return sendMessage(res, change);
|
||||
}
|
||||
else{
|
||||
return sendError(res, 'cant change');
|
||||
}
|
||||
}
|
||||
module.exports = changePassword;
|
||||
Reference in a new issue