mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { Container, Inject } from 'typedi';
|
|
import AuthenticationService from '@/services/Authentication/AuthApplication';
|
|
|
|
export default class WelcomeEmailJob {
|
|
/**
|
|
* Constructor method.
|
|
* @param {Agenda} agenda
|
|
*/
|
|
constructor(agenda) {
|
|
agenda.define(
|
|
'reset-password-mail',
|
|
{ priority: 'high' },
|
|
this.handler.bind(this),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Handle send welcome mail job.
|
|
* @param {Job} job
|
|
* @param {Function} done
|
|
*/
|
|
public async handler(job, done: Function): Promise<void> {
|
|
const { data } = job.attrs;
|
|
const { user, token } = data;
|
|
const Logger = Container.get('logger');
|
|
const authService = Container.get(AuthenticationService);
|
|
|
|
Logger.info(`[send_reset_password] started.`, { data });
|
|
|
|
try {
|
|
await authService.mailMessages.sendResetPasswordMessage(user, token);
|
|
Logger.info(`[send_reset_password] finished.`, { data });
|
|
done()
|
|
} catch (error) {
|
|
Logger.error(`[send_reset_password] error.`, { data, error });
|
|
done(error);
|
|
}
|
|
}
|
|
}
|