diff --git a/src/auth/auth.module.ts b/src/auth/auth.module.ts index 59e2636..dc38ebc 100644 --- a/src/auth/auth.module.ts +++ b/src/auth/auth.module.ts @@ -1,5 +1,4 @@ import { Module } from '@nestjs/common'; -import { ConfigModule, ConfigService } from '@nestjs/config'; import { JwtModule } from '@nestjs/jwt'; import { UserModule } from '../users/user.module'; import { MongooseModule } from '@nestjs/mongoose'; @@ -13,6 +12,8 @@ import { NotificationService } from 'src/notification/notification.service'; import { NotificationModule } from 'src/notification/notification.module'; import { RolesService } from 'src/users/services/roles.service'; import { ResetPasswordSchema } from './entities/reset-password.schema'; +import { ResetPasswordController } from './controllers/reset-password.controller'; +import { ResetPasswordService } from './services/reset-password.service'; @Module({ imports: [ @@ -20,7 +21,9 @@ import { ResetPasswordSchema } from './entities/reset-password.schema'; MongooseModule.forFeature([ { name: AuthToken.name, schema: AuthTokenSchema }, ]), - MongooseModule.forFeature([{ name: 'ResetPassword', schema: ResetPasswordSchema }]), + MongooseModule.forFeature([ + { name: 'ResetPassword', schema: ResetPasswordSchema }, + ]), JwtModule.register({ global: true, secret: process.env.JWT_SECRET_KEY, @@ -29,10 +32,15 @@ import { ResetPasswordSchema } from './entities/reset-password.schema'; EmailModule, BullModule.registerQueue({ name: 'email' }), NotificationModule, - ], - controllers: [AuthController], - providers: [AuthService, EmailService, NotificationService, RolesService], + controllers: [AuthController, ResetPasswordController], + providers: [ + AuthService, + EmailService, + NotificationService, + RolesService, + ResetPasswordService, + ], exports: [MongooseModule, RolesService], }) export class AuthModule {} diff --git a/src/auth/services/reset-password.service.ts b/src/auth/services/reset-password.service.ts index 4ee81db..3707711 100644 --- a/src/auth/services/reset-password.service.ts +++ b/src/auth/services/reset-password.service.ts @@ -12,12 +12,12 @@ import { import { User, UserDocument } from 'src/users/entities/user.schema'; import { v4 as uuidv4 } from 'uuid'; import * as moment from 'moment'; -import { EmailService } from 'src/email/email.service'; import * as bcrypt from 'bcrypt'; import { ResetPasswordDto } from '../dto/reset-password-token.dto'; import { NotificationService } from 'src/notification/notification.service'; import { resetPasswordNotification } from 'src/notification/notifiables/resetPasswordNotification.notification'; import { forgotPasswordNotification } from 'src/notification/notifiables/forgotPasswordNotification.notification'; +import { InjectQueue } from '@nestjs/bull'; @Injectable() export class ResetPasswordService { @@ -28,8 +28,8 @@ export class ResetPasswordService { @InjectModel(User.name) private UserModel: Model, - private notificationService: NotificationService, + @InjectQueue('email') private emailQueue, ) {} async sendForgotPasswordEmail(email: string) { @@ -53,7 +53,7 @@ export class ResetPasswordService { }); this.notificationService.sendNotification( - new forgotPasswordNotification(user, resetPassword), + new forgotPasswordNotification(user, resetPassword, this.emailQueue), ); }