forked from Yara724/api
Showing a valid message while the OTP is still valid, instead of 400
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
# ---------------------------------------------
|
||||
# 🔧 Application Environment
|
||||
# ---------------------------------------------
|
||||
NODE_ENV =
|
||||
PORT =
|
||||
# ---------------------------------------------
|
||||
# 🌐 Application URLs
|
||||
# ---------------------------------------------
|
||||
URL =
|
||||
BASE_URL_DEV =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 📄 Swagger / API Documentation
|
||||
# ---------------------------------------------
|
||||
SWAGGER_USER_DEV =
|
||||
SWAGGER_PASSWORD_DEV =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🗄️ Database (MongoDB)
|
||||
# ---------------------------------------------
|
||||
MONGO_HOST =
|
||||
MONGO_PORT =
|
||||
MONGO_USER =
|
||||
MONGO_PASS =
|
||||
MONGO_DB_NAME =
|
||||
MONGO_OPTIONS =
|
||||
MONGO_TLS =
|
||||
MONGO_TLS_ALLOW_INVALID_CERTS =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🔐 Authentication / Security
|
||||
# ---------------------------------------------
|
||||
JWT_SECRET =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🧩 SanHub Microservice
|
||||
# ---------------------------------------------
|
||||
SANHUB_BASE_URL =
|
||||
SANHUB_URL_LOGIN =
|
||||
SANHUB_USERNAME =
|
||||
SANHUB_PASSWORD =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🤖 AI Services
|
||||
# ---------------------------------------------
|
||||
AI_URL =
|
||||
AI_URL_V2 =
|
||||
AI_USERNAME =
|
||||
AI_PASSWORD =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 📩 SMS
|
||||
# ---------------------------------------------
|
||||
SMS_PROVIDER =
|
||||
SMS_API_KEY =
|
||||
AUTH_SMS_TEMPLATE =
|
||||
EXP_OTP_TIME =
|
||||
|
||||
# ---------------------------------------------
|
||||
# ⚙️ Application Features / Flags
|
||||
# ---------------------------------------------
|
||||
AUTO_CLIENT_KEY_ENABLED =
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🔗 Other Internal Services
|
||||
# ---------------------------------------------
|
||||
TEJARAT_INQUIRY_EMAIL =
|
||||
TEJARAT_INQUIRY_PASSWORD =
|
||||
|
||||
PARSIAN_API_KEY =
|
||||
PARSIAN_BASIC_TOKEN =
|
||||
PARSIAN_SMS_URL =
|
||||
@@ -30,6 +30,7 @@ export class UserAuthController {
|
||||
linkToken: body.linkToken,
|
||||
linkContext: body.linkContext,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
throw new HttpException(res, HttpStatus.ACCEPTED);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user