1
0
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:
2026-07-11 11:39:36 +03:30
parent 80122e7772
commit b65d9bfe81
2 changed files with 32 additions and 6 deletions

View File

@@ -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> {
@@ -62,6 +64,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);
}