mirror of
https://bitbucket.org/tagfer_team/tagfer-server.git
synced 2025-12-25 03:37:38 +00:00
Reset password through email
This commit is contained in:
parent
35f15fd215
commit
b9a38a3d96
@ -13,6 +13,7 @@ function router(app) {
|
||||
app.post('/auth/phone/verify', AuthHandlers.verifyPhoneCode);
|
||||
app.post('/auth/signin', AuthHandlers.signin);
|
||||
app.put('/auth/signup', AuthHandlers.signup);
|
||||
app.post('/auth/passwordReset', AuthHandlers.sendPasswordResetEmail)
|
||||
|
||||
// Users Endpoints
|
||||
app.get('/users/by/phone', UserHandlers.findNetworkByPhone);
|
||||
|
||||
@ -61,6 +61,14 @@ function createNewUser(user) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a password reset email
|
||||
* @param {email} email
|
||||
*/
|
||||
function resetPassword(email) {
|
||||
return firebase.auth().sendPasswordResetEmail(email).catch( error => { throw { error: error.code }; });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} phone
|
||||
@ -157,7 +165,8 @@ module.exports = {
|
||||
signinWithTagferId,
|
||||
signinWithEmail,
|
||||
createNewUser,
|
||||
createNewSessionId
|
||||
createNewSessionId,
|
||||
resetPassword
|
||||
};
|
||||
|
||||
// function signinWithTagferId1(tagferId, password, callback) {
|
||||
|
||||
@ -107,10 +107,27 @@ function signup(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint: auth/passwordReset
|
||||
* Send a reset password link to the email
|
||||
* @param {Object} req { email: String }
|
||||
* @param {Object} res {} | { error: String }
|
||||
*/
|
||||
function sendPasswordResetEmail(req, res) {
|
||||
const { email } = req.body;
|
||||
const verifier = () => email;
|
||||
if (!utils.isAppSecretValid(req,res) || !utils.isBodyValid(verifier, res)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dao.resetPassword(email).then(() => res.json({}) ).catch( error => res.json(error))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doesAttributeExist,
|
||||
sendPhoneCode,
|
||||
verifyPhoneCode,
|
||||
signin,
|
||||
signup
|
||||
signup,
|
||||
sendPasswordResetEmail
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user