diff --git a/packages/handlers/handle-generate-docx.js b/packages/handlers/handle-generate-docx.js index faa488e..4090734 100644 --- a/packages/handlers/handle-generate-docx.js +++ b/packages/handlers/handle-generate-docx.js @@ -126,9 +126,6 @@ function buildRencanaKegiatan (body, kegiatanKeys) { */ const handleGenerateDocx = async (body) => { // Validate hCaptcha response before proceeding with document generation - if (!body['h-captcha-response']) { - return { status: 400, message: 'hCaptcha response token is missing' } - } if (!await handleHCaptchaValidation(body)) { return { status: 400, message: 'hCaptcha validation failed' } } diff --git a/packages/handlers/handle-hcaptcha-validation.js b/packages/handlers/handle-hcaptcha-validation.js index 7852f78..e4ed325 100644 --- a/packages/handlers/handle-hcaptcha-validation.js +++ b/packages/handlers/handle-hcaptcha-validation.js @@ -6,8 +6,17 @@ import { verify } from 'hcaptcha' * @returns {Promise} - A promise that resolves to true if the hCaptcha validation is successful, or false otherwise. */ const handleHCaptchaValidation = async (body) => { - const { 'h-captcha-response': hCaptchaResponse } = body const secret = String(process.env.HCAPTCHA_SECRET_KEY) + if (!secret) { + console.warn('Bypassing hCaptcha validation because HCAPTCHA_SECRET_KEY is not set in environment variables.') + return true + } + + const { 'h-captcha-response': hCaptchaResponse } = body + if (!hCaptchaResponse) { + console.warn('hCaptcha response token is missing in the request body.') + return false + } try { const result = await verify(secret, hCaptchaResponse) diff --git a/resources/views/home.ejs b/resources/views/home.ejs index a9c604b..34be33f 100644 --- a/resources/views/home.ejs +++ b/resources/views/home.ejs @@ -376,7 +376,11 @@ Export Template -
+ + <% if (META.HCAPTCHA_SITE_KEY) { %> +
+ <% } %> + @@ -390,7 +394,9 @@ - + <% if (META.HCAPTCHA_SITE_KEY) { %> + + <% } %>