mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix: issues in authentication mail messages.
This commit is contained in:
@@ -2,8 +2,17 @@ import { Container, Inject } from 'typedi';
|
||||
import AuthenticationService from '@/services/Authentication';
|
||||
|
||||
export default class WelcomeEmailJob {
|
||||
@Inject()
|
||||
authService: AuthenticationService;
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {Agenda} agenda
|
||||
*/
|
||||
constructor(agenda) {
|
||||
agenda.define(
|
||||
'reset-password-mail',
|
||||
{ priority: 'high' },
|
||||
this.handler.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle send welcome mail job.
|
||||
@@ -11,17 +20,18 @@ export default class WelcomeEmailJob {
|
||||
* @param {Function} done
|
||||
*/
|
||||
public async handler(job, done: Function): Promise<void> {
|
||||
const { email, organizationName, firstName } = job.attrs.data;
|
||||
const { user, token } = job.attrs.data;
|
||||
const Logger = Container.get('logger');
|
||||
const authService = Container.get(AuthenticationService);
|
||||
|
||||
Logger.info(`Send reset password mail - started: ${job.attrs.data}`);
|
||||
Logger.info(`[send_reset_password] started: ${job.attrs.data}`);
|
||||
|
||||
try {
|
||||
await this.authService.mailMessages.sendResetPasswordMessage();
|
||||
Logger.info(`Send reset password mail - finished: ${job.attrs.data}`);
|
||||
await authService.mailMessages.sendResetPasswordMessage(user, token);
|
||||
Logger.info(`[send_reset_password] finished: ${job.attrs.data}`);
|
||||
done()
|
||||
} catch (error) {
|
||||
Logger.info(`Send reset password mail - error: ${job.attrs.data}, error: ${error}`);
|
||||
Logger.info(`[send_reset_password] error: ${job.attrs.data}, error: ${error}`);
|
||||
done(error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user