forked from Yara724/api
driverId problem fixed , also added a captcha required env called : CAPTCHA_ENABLED= to disable or enable CAPTCHA in development
This commit is contained in:
@@ -13,6 +13,7 @@ import { HashService } from "src/utils/hash/hash.service";
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class CaptchaChallengeService {
|
export class CaptchaChallengeService {
|
||||||
private readonly isDev: boolean;
|
private readonly isDev: boolean;
|
||||||
|
private readonly captchaEnabled: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly captchaService: CaptchaService,
|
private readonly captchaService: CaptchaService,
|
||||||
@@ -21,6 +22,7 @@ export class CaptchaChallengeService {
|
|||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
) {
|
) {
|
||||||
this.isDev = this.configService.get<string>("NODE_ENV") === "development";
|
this.isDev = this.configService.get<string>("NODE_ENV") === "development";
|
||||||
|
this.captchaEnabled = this.configService.get<string>("CAPTCHA_ENABLED") !== "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
async issue(): Promise<CaptchaResponseDto> {
|
async issue(): Promise<CaptchaResponseDto> {
|
||||||
@@ -62,6 +64,11 @@ export class CaptchaChallengeService {
|
|||||||
captchaId: string | undefined,
|
captchaId: string | undefined,
|
||||||
answer: string | undefined,
|
answer: string | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// Skip captcha verification if disabled via environment variable
|
||||||
|
if (!this.captchaEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!captchaId?.trim()) {
|
if (!captchaId?.trim()) {
|
||||||
throwCaptchaAuthError(CaptchaAuthErrorCode.CAPTCHA_REQUIRED);
|
throwCaptchaAuthError(CaptchaAuthErrorCode.CAPTCHA_REQUIRED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3654,17 +3654,32 @@ export class ClaimRequestManagementService {
|
|||||||
const year = parseInt(str.slice(0, 4), 10);
|
const year = parseInt(str.slice(0, 4), 10);
|
||||||
const month = parseInt(str.slice(4, 6), 10);
|
const month = parseInt(str.slice(4, 6), 10);
|
||||||
const day = parseInt(str.slice(6, 8), 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 };
|
return { year, month, day };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delimited formats: "1364/06/10" or "1364-06-10"
|
// Delimited formats: "1364/06/10" or "1364-06-10"
|
||||||
const parts = str.split(/[/\-]/);
|
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 year = parseInt(parts[0], 10);
|
||||||
const month = parseInt(parts[1], 10);
|
const month = parseInt(parts[1], 10);
|
||||||
const day = parseInt(parts[2], 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 };
|
return { year, month, day };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3780,8 +3795,12 @@ export class ClaimRequestManagementService {
|
|||||||
String(party?.person?.userId ?? "") === String(guiltyUserId),
|
String(party?.person?.userId ?? "") === String(guiltyUserId),
|
||||||
)
|
)
|
||||||
: null;
|
: 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 carType = input.claimCase?.vehicle?.carType as string | undefined;
|
||||||
const vehicleKindId = await this.resolveVehicleKindId(
|
const vehicleKindId = await this.resolveVehicleKindId(
|
||||||
@@ -3843,7 +3862,7 @@ export class ClaimRequestManagementService {
|
|||||||
VehicleKindId: vehicleKindId,
|
VehicleKindId: vehicleKindId,
|
||||||
VIN: inquiryMapped.VIN ?? inquiryRaw.VIN ?? null,
|
VIN: inquiryMapped.VIN ?? inquiryRaw.VIN ?? null,
|
||||||
AccidentVehicleUsedId: input.defaults.AccidentVehicleUsedId,
|
AccidentVehicleUsedId: input.defaults.AccidentVehicleUsedId,
|
||||||
PolicyCINumber: blamedThirdPolicyCode,
|
PolicyCINumber: policyCINumber,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user