feature/refactor-login #19

Merged
igorpropisnov merged 26 commits from feature/refactor-login into main 2024-09-19 13:58:12 +02:00
1 changed files with 10 additions and 15 deletions
Showing only changes of commit c9a8e9967a - Show all commits

View File

@ -88,24 +88,19 @@ export class EmailVerificationService {
emailToVerify: string emailToVerify: string
): Promise<SuccessDto> { ): Promise<SuccessDto> {
try { try {
const findTokenAndEmail: EmailVerification | null = const token = await this.emailVerifyRepository.findByTokenAndEmail(
await this.emailVerifyRepository.findValidVerification( tokenToVerify,
tokenToVerify, emailToVerify
emailToVerify );
);
if (!findTokenAndEmail) { if (!token) {
const expiredToken = throw new TokenExpiredException();
await this.emailVerifyRepository.findByTokenAndEmail( }
tokenToVerify,
emailToVerify
);
if (expiredToken) { const currentDate = new Date();
throw new TokenExpiredException();
}
return { success: false }; if (token.expiresAt.getTime() < currentDate.getTime()) {
throw new TokenExpiredException();
} }
await this.emailVerifyRepository.removeEmailVerificationByTokenAndEmail( await this.emailVerifyRepository.removeEmailVerificationByTokenAndEmail(