forked from Yara724/api
Showing a valid message while the OTP is still valid, instead of 400
This commit is contained in:
@@ -30,6 +30,7 @@ export class UserAuthController {
|
|||||||
linkToken: body.linkToken,
|
linkToken: body.linkToken,
|
||||||
linkContext: body.linkContext,
|
linkContext: body.linkContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
throw new HttpException(res, HttpStatus.ACCEPTED);
|
throw new HttpException(res, HttpStatus.ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ export function userAuthErrorBody(code: UserAuthErrorCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function throwUserAuthError(code: UserAuthErrorCode): never {
|
export function throwUserAuthError(code: UserAuthErrorCode): never {
|
||||||
if (code === UserAuthErrorCode.OTP_REQUEST_TOO_SOON) {
|
// if (code === UserAuthErrorCode.OTP_REQUEST_TOO_SOON) {
|
||||||
throw new BadRequestException(userAuthErrorBody(code));
|
// throw new BadRequestException(userAuthErrorBody(code));
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (code === UserAuthErrorCode.LINK_MOBILE_MISMATCH) {
|
if (code === UserAuthErrorCode.LINK_MOBILE_MISMATCH) {
|
||||||
throw new ForbiddenException(userAuthErrorBody(code));
|
throw new ForbiddenException(userAuthErrorBody(code));
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ export class UserAuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isOtpExpiryActive(userExist.otpExpire, nowMs)) {
|
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);
|
await this.smsSender(otp, canonicalMobile);
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ export class UserLoginDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LoginDtoRs extends UserModel {
|
export class LoginDtoRs extends UserModel {
|
||||||
|
@ApiProperty({ type: "string" })
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
example: "09226187419",
|
example: "09226187419",
|
||||||
type: "string",
|
type: "string",
|
||||||
@@ -61,8 +63,10 @@ export class LoginDtoRs extends UserModel {
|
|||||||
username: string;
|
username: string;
|
||||||
mobile: string;
|
mobile: string;
|
||||||
nationalCode: string;
|
nationalCode: string;
|
||||||
constructor(loginData) {
|
|
||||||
|
constructor(loginData, message: string = "") {
|
||||||
super();
|
super();
|
||||||
this.mobile = loginData.mobile;
|
this.mobile = loginData.mobile;
|
||||||
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user