Refactor CAPTCHA setup verification
Eliminated constant verification of CAPTCHA setup across different modules and refactored the CAPTCHA token verification process. This commit relies on config parameters to decide whether to verify CAPTCHA or not, instead of environment variables. It also reforms the token submission to CAPTCHA service for consistency and clarity.
This commit is contained in:
@@ -19,12 +19,6 @@ interface HandlerParams<Body> {
|
||||
body: Body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name IS_CAPTCHA_SETUP
|
||||
* @description Check if the CAPTCHA is setup
|
||||
*/
|
||||
const IS_CAPTCHA_SETUP = !!process.env.CAPTCHA_SECRET_TOKEN;
|
||||
|
||||
/**
|
||||
* Enhanced route handler function.
|
||||
*
|
||||
@@ -69,7 +63,8 @@ export const enhanceRouteHandler = <
|
||||
* This function takes a request object as an argument and returns a response object.
|
||||
*/
|
||||
return async function routeHandler(request: NextRequest) {
|
||||
const shouldVerifyCaptcha = params?.captcha ?? IS_CAPTCHA_SETUP;
|
||||
// Check if the captcha token should be verified
|
||||
const shouldVerifyCaptcha = params?.captcha ?? false;
|
||||
|
||||
// Verify the captcha token if required and setup
|
||||
if (shouldVerifyCaptcha) {
|
||||
|
||||
Reference in New Issue
Block a user