mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 22:13:20 +03:00
3af0110bcc
no-issue
36 lines
840 B
JavaScript
36 lines
840 B
JavaScript
module.exports = function ({
|
|
createMember,
|
|
updateMember,
|
|
getMember,
|
|
validateMember,
|
|
sendEmail,
|
|
encodeToken,
|
|
decodeToken
|
|
}) {
|
|
function requestPasswordReset({email}) {
|
|
return getMember({email}).then((member) => {
|
|
return encodeToken({
|
|
sub: member.id
|
|
}).then((token) => {
|
|
return sendEmail(member, {token});
|
|
});
|
|
}, (/*err*/) => {
|
|
// Ignore user not found err;
|
|
});
|
|
}
|
|
|
|
function resetPassword({token, password}) {
|
|
return decodeToken(token).then(({sub}) => {
|
|
return updateMember({id: sub}, {password});
|
|
});
|
|
}
|
|
|
|
return {
|
|
requestPasswordReset,
|
|
resetPassword,
|
|
create: createMember,
|
|
validate: validateMember,
|
|
get: getMember
|
|
};
|
|
};
|