mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
add server to monorepo.
This commit is contained in:
39
packages/server/src/jobs/ResetPasswordMail.ts
Normal file
39
packages/server/src/jobs/ResetPasswordMail.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Container, Inject } from 'typedi';
|
||||
import AuthenticationService from '@/services/Authentication';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user