fix token issue
This commit is contained in:
parent
8a1089ce9d
commit
c9a8e9967a
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue