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
): Promise<SuccessDto> {
try {
const findTokenAndEmail: EmailVerification | null =
await this.emailVerifyRepository.findValidVerification(
tokenToVerify,
emailToVerify
);
const token = await this.emailVerifyRepository.findByTokenAndEmail(
tokenToVerify,
emailToVerify
);
if (!findTokenAndEmail) {
const expiredToken =
await this.emailVerifyRepository.findByTokenAndEmail(
tokenToVerify,
emailToVerify
);
if (!token) {
throw new TokenExpiredException();
}
if (expiredToken) {
throw new TokenExpiredException();
}
const currentDate = new Date();
return { success: false };
if (token.expiresAt.getTime() < currentDate.getTime()) {
throw new TokenExpiredException();
}
await this.emailVerifyRepository.removeEmailVerificationByTokenAndEmail(