29 lines
723 B
JavaScript
29 lines
723 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('recoverPassword', {
|
|
description: 'Send email to the user',
|
|
accepts: [
|
|
{
|
|
arg: 'email',
|
|
type: 'string',
|
|
description: 'The email of user',
|
|
required: true
|
|
}
|
|
],
|
|
http: {
|
|
path: `/recoverPassword`,
|
|
verb: 'POST'
|
|
}
|
|
});
|
|
|
|
Self.recoverPassword = async function(email) {
|
|
try {
|
|
await Self.resetPassword({email, emailTemplate: 'recover-password'});
|
|
} catch (err) {
|
|
if (err.code === 'EMAIL_NOT_FOUND')
|
|
return;
|
|
else
|
|
throw err;
|
|
}
|
|
};
|
|
};
|