1
0
forked from Yara724/api

Showing a valid message while the OTP is still valid, instead of 400

This commit is contained in:
SepehrYahyaee
2026-05-30 11:37:09 +03:30
parent 245160bfc2
commit da298a3350
5 changed files with 11 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ export class UserAuthController {
linkToken: body.linkToken,
linkContext: body.linkContext,
});
if (res) {
throw new HttpException(res, HttpStatus.ACCEPTED);
}

View File

@@ -34,9 +34,9 @@ export function userAuthErrorBody(code: UserAuthErrorCode) {
}
export function throwUserAuthError(code: UserAuthErrorCode): never {
if (code === UserAuthErrorCode.OTP_REQUEST_TOO_SOON) {
throw new BadRequestException(userAuthErrorBody(code));
}
// if (code === UserAuthErrorCode.OTP_REQUEST_TOO_SOON) {
// throw new BadRequestException(userAuthErrorBody(code));
// }
if (code === UserAuthErrorCode.LINK_MOBILE_MISMATCH) {
throw new ForbiddenException(userAuthErrorBody(code));

View File

@@ -139,7 +139,8 @@ export class UserAuthService {
}
if (isOtpExpiryActive(userExist.otpExpire, nowMs)) {
throwUserAuthError(UserAuthErrorCode.OTP_REQUEST_TOO_SOON);
// throwUserAuthError(UserAuthErrorCode.OTP_REQUEST_TOO_SOON);
return new LoginDtoRs(userExist, "OTP Still valid");
}
await this.smsSender(otp, canonicalMobile);

View File

@@ -35,7 +35,9 @@ export class UserLoginDto {
}
export class LoginDtoRs extends UserModel {
@ApiProperty({ type: "string" })
message: string;
@ApiProperty({
example: "09226187419",
type: "string",
@@ -61,8 +63,10 @@ export class LoginDtoRs extends UserModel {
username: string;
mobile: string;
nationalCode: string;
constructor(loginData) {
constructor(loginData, message: string = "") {
super();
this.mobile = loginData.mobile;
this.message = message;
}
}