Skip to content

Commit

Permalink
fix: add reset password service to auth module
Browse files Browse the repository at this point in the history
  • Loading branch information
alpemreelmas committed May 12, 2024
1 parent f00c674 commit 905e315
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 13 additions & 5 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -13,14 +12,18 @@ 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: [
UserModule,
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,
Expand All @@ -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 {}
6 changes: 3 additions & 3 deletions src/auth/services/reset-password.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,8 +28,8 @@ export class ResetPasswordService {

@InjectModel(User.name)
private UserModel: Model<UserDocument>,

private notificationService: NotificationService,
@InjectQueue('email') private emailQueue,
) {}

async sendForgotPasswordEmail(email: string) {
Expand All @@ -53,7 +53,7 @@ export class ResetPasswordService {
});

this.notificationService.sendNotification(
new forgotPasswordNotification(user, resetPassword),
new forgotPasswordNotification(user, resetPassword, this.emailQueue),
);
}

Expand Down

0 comments on commit 905e315

Please sign in to comment.