const LoopBackContext = require('loopback-context'); const {Email} = require('vn-print'); module.exports = function(Self) { Self.on('resetPasswordRequest', async function(info) { const loopBackContext = LoopBackContext.getCurrentContext(); const httpCtx = {req: loopBackContext.active}; const httpRequest = httpCtx.req.http.req; const headers = httpRequest.headers; const origin = headers.origin; const user = await Self.app.models.Account.findById(info.user.id); const params = { recipient: info.email, lang: user.lang, url: `${origin}/#!/reset-password?access_token=${info.accessToken.id}` }; const email = new Email('recover-password', params); return email.send(); }); };