salix/back/methods/account/recover-password.js

28 lines
638 B
JavaScript
Raw Normal View History

2022-09-20 13:21:01 +00:00
module.exports = Self => {
2022-11-09 13:51:30 +00:00
Self.remoteMethod('recoverPassword', {
2022-09-20 13:21:01 +00:00
description: 'Send email to the user',
accepts: [
{
arg: 'email',
type: 'string',
description: 'The email of user',
2022-09-21 13:15:19 +00:00
required: true
2022-09-20 13:21:01 +00:00
}
],
http: {
path: `/recoverPassword`,
2022-09-21 13:15:19 +00:00
verb: 'POST'
2022-09-20 13:21:01 +00:00
}
});
2022-11-09 13:51:30 +00:00
Self.recoverPassword = async function(email) {
2022-09-20 13:21:01 +00:00
const models = Self.app.models;
2022-11-09 13:51:30 +00:00
try {
await models.user.resetPassword({email});
} catch (e) {
2022-09-28 10:20:29 +00:00
return;
2022-11-09 13:51:30 +00:00
}
2022-09-20 13:21:01 +00:00
};
};