mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
refactor: Authentication service.
This commit is contained in:
@@ -2,6 +2,7 @@ import { Container } from 'typedi';
|
||||
import LoggerInstance from '@/services/Logger';
|
||||
import agendaFactory from '@/loaders/agenda';
|
||||
import SmsClientLoader from '@/loaders/smsClient';
|
||||
import mailInstance from '@/loaders/mail';
|
||||
|
||||
export default ({ mongoConnection, knex }) => {
|
||||
try {
|
||||
@@ -20,6 +21,9 @@ export default ({ mongoConnection, knex }) => {
|
||||
Container.set('SMSClient', smsClientInstance);
|
||||
LoggerInstance.info('SMS client has been injected into container');
|
||||
|
||||
Container.set('mail', mailInstance);
|
||||
LoggerInstance.info('Mail instance has been injected into container');
|
||||
|
||||
return { agenda: agendaInstance };
|
||||
} catch (e) {
|
||||
LoggerInstance.error('Error on dependency injector loader: %o', e);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// Here we import all events.
|
||||
import '@/subscribers/authentication';
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import Agenda from 'agenda';
|
||||
import WelcomeEmailJob from '@/Jobs/welcomeEmail';
|
||||
import ResetPasswordMailJob from '@/Jobs/ResetPasswordMail';
|
||||
import ComputeItemCost from '@/Jobs/ComputeItemCost';
|
||||
import RewriteInvoicesJournalEntries from '@/jobs/writeInvoicesJEntries';
|
||||
import SendVoucherViaPhoneJob from '@/jobs/SendVoucherPhone';
|
||||
import SendVoucherViaEmailJob from '@/jobs/SendVoucherEmail';
|
||||
import SendSMSNotificationSubscribeEnd from '@/jobs/SMSNotificationSubscribeEnd';
|
||||
import SendSMSNotificationTrialEnd from '@/jobs/SMSNotificationTrialEnd';
|
||||
import SendMailNotificationSubscribeEnd from '@/jobs/MailNotificationSubscribeEnd';
|
||||
import SendMailNotificationTrialEnd from '@/jobs/MailNotificationTrialEnd';
|
||||
import UserInviteMailJob from '@/jobs/UserInviteMail';
|
||||
|
||||
export default ({ agenda }: { agenda: Agenda }) => {
|
||||
agenda.define(
|
||||
@@ -11,6 +17,16 @@ export default ({ agenda }: { agenda: Agenda }) => {
|
||||
{ priority: 'high' },
|
||||
new WelcomeEmailJob().handler,
|
||||
);
|
||||
agenda.define(
|
||||
'reset-password-mail',
|
||||
{ priority: 'high' },
|
||||
new ResetPasswordMailJob().handler,
|
||||
);
|
||||
agenda.define(
|
||||
'user-invite-mail',
|
||||
{ priority: 'high' },
|
||||
new UserInviteMailJob().handler,
|
||||
)
|
||||
agenda.define(
|
||||
'compute-item-cost',
|
||||
{ priority: 'high', concurrency: 20 },
|
||||
@@ -31,21 +47,25 @@ export default ({ agenda }: { agenda: Agenda }) => {
|
||||
{ priority: 'high', concurrency: 1, },
|
||||
new SendVoucherViaEmailJob().handler,
|
||||
);
|
||||
// agenda.define(
|
||||
// 'send-sms-notification-subscribe-end',
|
||||
// { priority: 'high', concurrency: 1, },
|
||||
// );
|
||||
// agenda.define(
|
||||
// 'send-mail-notification-subscribe-end',
|
||||
// { priority: 'high', concurrency: 1, },
|
||||
// );
|
||||
// agenda.define(
|
||||
// 'send-sms-notification-trial-end',
|
||||
// { priority: 'high', concurrency: 1, },
|
||||
// );
|
||||
// agenda.define(
|
||||
// 'send-mail-notification-trial-end',
|
||||
// { priority: 'high', concurrency: 1, },
|
||||
// );
|
||||
agenda.define(
|
||||
'send-sms-notification-subscribe-end',
|
||||
{ priority: 'nromal', concurrency: 1, },
|
||||
new SendSMSNotificationSubscribeEnd().handler,
|
||||
);
|
||||
agenda.define(
|
||||
'send-sms-notification-trial-end',
|
||||
{ priority: 'normal', concurrency: 1, },
|
||||
new SendSMSNotificationTrialEnd().handler,
|
||||
);
|
||||
agenda.define(
|
||||
'send-mail-notification-subscribe-end',
|
||||
{ priority: 'high', concurrency: 1, },
|
||||
new SendMailNotificationSubscribeEnd().handler
|
||||
);
|
||||
agenda.define(
|
||||
'send-mail-notification-trial-end',
|
||||
{ priority: 'high', concurrency: 1, },
|
||||
new SendMailNotificationTrialEnd().handler
|
||||
);
|
||||
agenda.start();
|
||||
};
|
||||
|
||||
15
server/src/loaders/mail.ts
Normal file
15
server/src/loaders/mail.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
import config from '@/../config/config';
|
||||
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: config.mail.host,
|
||||
port: config.mail.port,
|
||||
secure: config.mail.secure, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: config.mail.username,
|
||||
pass: config.mail.password,
|
||||
},
|
||||
});
|
||||
|
||||
export default transporter;
|
||||
Reference in New Issue
Block a user