mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
Merge pull request #56 from HamzaSha1/ZOD-344-after-a-child-completes-registration-using-the-qr-code-the-same-qr-code-remains-valid-and-allows-the-child-to-register-again-instead-of-expiring
ZOD-344-Add QR code validation error handling and localization support
This commit is contained in:
@ -19,6 +19,10 @@
|
||||
"TOKEN_EXPIRED": "رمز المستخدم منتهي الصلاحية."
|
||||
},
|
||||
|
||||
"QR": {
|
||||
"CODE_USED_OR_EXPIRED": "تم استخدام رمز QR مسبقًا أو انتهت صلاحيته."
|
||||
},
|
||||
|
||||
"USER": {
|
||||
"PHONE_ALREADY_VERIFIED": "تم التحقق من رقم الهاتف بالفعل.",
|
||||
"EMAIL_ALREADY_VERIFIED": "تم التحقق من عنوان البريد الإلكتروني بالفعل.",
|
||||
|
||||
@ -19,6 +19,10 @@
|
||||
"TOKEN_EXPIRED": "The user token has expired."
|
||||
},
|
||||
|
||||
"QR": {
|
||||
"CODE_USED_OR_EXPIRED": "The QR code has already been used or expired."
|
||||
},
|
||||
|
||||
"USER": {
|
||||
"PHONE_ALREADY_VERIFIED": "The phone number has already been verified.",
|
||||
"EMAIL_ALREADY_VERIFIED": "The email address has already been verified.",
|
||||
|
||||
@ -5,6 +5,7 @@ import { Roles } from '~/auth/enums';
|
||||
import { CardService, TransactionService } from '~/card/services';
|
||||
import { NeoLeapService } from '~/common/modules/neoleap/services';
|
||||
import { PageOptionsRequestDto } from '~/core/dtos';
|
||||
import { ErrorCategory } from '~/core/enums';
|
||||
import { setIf } from '~/core/utils';
|
||||
import { CustomerService } from '~/customer/services';
|
||||
import { DocumentService, OciService } from '~/document/services';
|
||||
@ -158,7 +159,14 @@ export class JuniorService {
|
||||
async validateToken(token: string) {
|
||||
this.logger.log(`Validating token ${token}`);
|
||||
const juniorId = await this.userTokenService.validateToken(token, UserType.JUNIOR);
|
||||
return this.findJuniorById(juniorId!, true);
|
||||
const junior = await this.findJuniorById(juniorId!, true);
|
||||
|
||||
if (junior.customer?.user?.password) {
|
||||
this.logger.error(`Token ${token} already used for junior ${juniorId}`);
|
||||
throw new BadRequestException({ message: 'QR.CODE_USED_OR_EXPIRED', category: ErrorCategory.BUSINESS_ERROR });
|
||||
}
|
||||
|
||||
return junior;
|
||||
}
|
||||
|
||||
async generateToken(juniorId: string) {
|
||||
|
||||
Reference in New Issue
Block a user