user model
gitea/salix/pipeline/head This commit is unstable
Details
gitea/salix/pipeline/head This commit is unstable
Details
This commit is contained in:
parent
36894c31de
commit
5c9bc47235
|
@ -0,0 +1,26 @@
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = function(Self) {
|
||||||
|
function getUrl() {
|
||||||
|
return Self.app.get('rootUrl') || app.get('url');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFrom() {
|
||||||
|
return Self.dataSources.email.settings.transports[0].auth.from;
|
||||||
|
}
|
||||||
|
|
||||||
|
Self.on('resetPasswordRequest', async function(info) {
|
||||||
|
const renderer = loopback.template(path.resolve(__dirname, '../../views/reset-password.ejs'));
|
||||||
|
const html = renderer({
|
||||||
|
url: `${getUrl()}#/reset-password?access_token=${info.accessToken.id}`
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.models.Email.send({
|
||||||
|
to: info.email,
|
||||||
|
from: getFrom(),
|
||||||
|
subject: 'Password reset',
|
||||||
|
html
|
||||||
|
});
|
||||||
|
console.log('> Sending password reset email to:', info.email);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue