forked from Yara724/api
Compare commits
4 Commits
54ae82aa38
...
1559a40213
| Author | SHA1 | Date | |
|---|---|---|---|
| 1559a40213 | |||
| ac7ee941b8 | |||
| 5d005d5eee | |||
| b65d9bfe81 |
@@ -36,6 +36,7 @@ MONGO_URI = 'mongodb://${MONGO_USER}:${MONGO_PASS}@${MONGO_HOST}:${MONGO_PORT}/$
|
||||
# ---------------------------------------------
|
||||
JWT_SECRET =
|
||||
JWT_EXPIRY =
|
||||
CAPTCHA_ENABLED = true
|
||||
|
||||
# ---------------------------------------------
|
||||
# 🧩 SanHub Microservice
|
||||
|
||||
@@ -13,6 +13,7 @@ import { HashService } from "src/utils/hash/hash.service";
|
||||
@Injectable()
|
||||
export class CaptchaChallengeService {
|
||||
private readonly isDev: boolean;
|
||||
private readonly captchaEnabled: boolean;
|
||||
|
||||
constructor(
|
||||
private readonly captchaService: CaptchaService,
|
||||
@@ -21,6 +22,7 @@ export class CaptchaChallengeService {
|
||||
private readonly configService: ConfigService,
|
||||
) {
|
||||
this.isDev = this.configService.get<string>("NODE_ENV") === "development";
|
||||
this.captchaEnabled = this.configService.get<string>("CAPTCHA_ENABLED") !== "false";
|
||||
}
|
||||
|
||||
async issue(): Promise<CaptchaResponseDto> {
|
||||
@@ -67,6 +69,11 @@ export class CaptchaChallengeService {
|
||||
captchaId: string | undefined,
|
||||
answer: string | undefined,
|
||||
): Promise<void> {
|
||||
// Skip captcha verification if disabled via environment variable
|
||||
if (!this.captchaEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!captchaId?.trim()) {
|
||||
throwCaptchaAuthError(CaptchaAuthErrorCode.CAPTCHA_REQUIRED);
|
||||
}
|
||||
|
||||
@@ -3654,17 +3654,32 @@ export class ClaimRequestManagementService {
|
||||
const year = parseInt(str.slice(0, 4), 10);
|
||||
const month = parseInt(str.slice(4, 6), 10);
|
||||
const day = parseInt(str.slice(6, 8), 10);
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
||||
this.logger.warn(
|
||||
`parseJalaliBirthday: failed to parse compact format "${str}" - year=${year}, month=${month}, day=${day}`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
return { year, month, day };
|
||||
}
|
||||
|
||||
// Delimited formats: "1364/06/10" or "1364-06-10"
|
||||
const parts = str.split(/[/\-]/);
|
||||
if (parts.length < 3) return null;
|
||||
if (parts.length < 3) {
|
||||
this.logger.warn(
|
||||
`parseJalaliBirthday: insufficient parts in "${str}" - got ${parts.length} parts`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const year = parseInt(parts[0], 10);
|
||||
const month = parseInt(parts[1], 10);
|
||||
const day = parseInt(parts[2], 10);
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
||||
this.logger.warn(
|
||||
`parseJalaliBirthday: failed to parse delimited format "${str}" - year=${year}, month=${month}, day=${day}`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
return { year, month, day };
|
||||
}
|
||||
|
||||
@@ -3780,8 +3795,12 @@ export class ClaimRequestManagementService {
|
||||
String(party?.person?.userId ?? "") === String(guiltyUserId),
|
||||
)
|
||||
: null;
|
||||
const blamedThirdPolicyCode =
|
||||
blamedParty?.vehicle?.inquiry?.mapped?.ThirdPolicyCode ?? null;
|
||||
|
||||
// Get PolicyCINumber from damaged party's inquiry (mapped or raw), not blamed party
|
||||
const policyCINumber =
|
||||
inquiryMapped.ThirdPolicyCode ??
|
||||
inquiryRaw.ThirdPolicyCode ??
|
||||
null;
|
||||
|
||||
const carType = input.claimCase?.vehicle?.carType as string | undefined;
|
||||
const vehicleKindId = await this.resolveVehicleKindId(
|
||||
@@ -3843,7 +3862,7 @@ export class ClaimRequestManagementService {
|
||||
VehicleKindId: vehicleKindId,
|
||||
VIN: inquiryMapped.VIN ?? inquiryRaw.VIN ?? null,
|
||||
AccidentVehicleUsedId: input.defaults.AccidentVehicleUsedId,
|
||||
PolicyCINumber: blamedThirdPolicyCode,
|
||||
PolicyCINumber: policyCINumber,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user