From a1f6b287245a48f885d4d7736c89de8f17b78d66 Mon Sep 17 00:00:00 2001 From: Bianca Paccola Date: Tue, 25 Jun 2024 21:39:21 -0300 Subject: [PATCH 1/2] =?UTF-8?q?add:=20alterando=20o=20c=C3=B3digo=20do=20l?= =?UTF-8?q?ogin=20para=20reenviar=20o=20email=20de=20confirma=C3=A7=C3=A3o?= =?UTF-8?q?=20ap=C3=B3s=20uma=20tentativa=20de=20login=20onde=20a=20conta?= =?UTF-8?q?=20ainda=20n=C3=A3o=20foi=20confirmada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/auth/auth.service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index af9830d..cebf248 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -6,6 +6,9 @@ import { InfoLoginDto } from './dtos/info-login.dto'; import { accessAttemptMessage } from './enums/message.enum'; import { UserRepository } from '../user/user.repository'; import { InfoEntity } from './entity/info.entity'; +import { MailService } from '../mails/mail.service'; +import { MentorEntity } from '../mentors/entities/mentor.entity'; +import { UserEntity } from '../user/entities/user.entity'; @Injectable() export class AuthService { @@ -13,6 +16,7 @@ export class AuthService { private mentorRepository: MentorRepository, private userRepository: UserRepository, private jwt: JwtService, + private mailService: MailService, ) {} async execute({ email, password, type}: InfoLoginDto) { @@ -22,7 +26,7 @@ export class AuthService { } else { info = await this.userRepository.findUserByEmail(email) } - this.infoConfirm(info); + this.infoConfirm(info, type); const passwordIsValid = await bcrypt.compare(password, info.password); @@ -52,7 +56,7 @@ export class AuthService { }; } - infoConfirm(info: InfoEntity) { + async infoConfirm(info: InfoEntity, type: string) { if (!info || info.deleted == true) { const message = "invalid e-mail or password" @@ -63,6 +67,10 @@ export class AuthService { if (!info.emailConfirmed) { const message = 'Your account is not activated yet. Check your e-mail inbox for instructions' + + if(type == 'mentor') await this.mailService.mentorSendCreationConfirmation(info as MentorEntity); + if(type == 'user') await this.mailService.userSendCreationConfirmation(info as UserEntity); + throw new HttpException({ message }, HttpStatus.NOT_FOUND) } From e8010c707024812444ce9df2b25883b552fd43d2 Mon Sep 17 00:00:00 2001 From: Bianca Paccola Date: Tue, 25 Jun 2024 23:58:09 -0300 Subject: [PATCH 2/2] =?UTF-8?q?add:=20alterando=20o=20c=C3=B3digo=20do=20l?= =?UTF-8?q?ogin=20para=20reenviar=20o=20email=20de=20confirma=C3=A7=C3=A3o?= =?UTF-8?q?=20ap=C3=B3s=20uma=20tentativa=20de=20login=20onde=20a=20conta?= =?UTF-8?q?=20ainda=20n=C3=A3o=20foi=20confirmada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/auth/auth.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index cebf248..1e5a2f1 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -26,7 +26,7 @@ export class AuthService { } else { info = await this.userRepository.findUserByEmail(email) } - this.infoConfirm(info, type); + await this.infoConfirm(info, type); const passwordIsValid = await bcrypt.compare(password, info.password); @@ -68,9 +68,9 @@ export class AuthService { const message = 'Your account is not activated yet. Check your e-mail inbox for instructions' - if(type == 'mentor') await this.mailService.mentorSendCreationConfirmation(info as MentorEntity); - if(type == 'user') await this.mailService.userSendCreationConfirmation(info as UserEntity); - + if(type == 'mentor') await this.mailService.mentorSendCreationConfirmation(info as MentorEntity) + if(type == 'user') await this.mailService.userSendCreationConfirmation(info as UserEntity) + throw new HttpException({ message }, HttpStatus.NOT_FOUND) }