mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 05:31:14 -05:00
Refactor: Simplify CAPTCHA bypass logic
This commit is contained in:
@@ -1,26 +1,17 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useAdminSettings } from './useAdminSettings';
|
||||
|
||||
export function useCaptchaBypass() {
|
||||
const { getSettingValue } = useAdminSettings();
|
||||
|
||||
// Layer 1: Check if environment allows bypass
|
||||
const environmentAllowsBypass = import.meta.env.VITE_ALLOW_CAPTCHA_BYPASS === 'true';
|
||||
|
||||
// Layer 2: Check if admin has enabled bypass
|
||||
const adminEnabledBypass = getSettingValue('auth.captcha_bypass_enabled', false) === true ||
|
||||
getSettingValue('auth.captcha_bypass_enabled', false) === 'true';
|
||||
|
||||
// Both layers must allow bypass
|
||||
const bypassEnabled = environmentAllowsBypass && adminEnabledBypass;
|
||||
// Single layer: Check if environment allows bypass
|
||||
const bypassEnabled = import.meta.env.VITE_ALLOW_CAPTCHA_BYPASS === 'true';
|
||||
|
||||
// Log warning if bypass is active
|
||||
useEffect(() => {
|
||||
if (bypassEnabled && typeof window !== 'undefined') {
|
||||
console.warn(
|
||||
'⚠️ CAPTCHA BYPASS IS ACTIVE\n' +
|
||||
'This should only be enabled in development/preview environments.\n' +
|
||||
'Verify VITE_ALLOW_CAPTCHA_BYPASS=false in production!'
|
||||
'CAPTCHA verification is disabled via VITE_ALLOW_CAPTCHA_BYPASS=true\n' +
|
||||
'This should ONLY be enabled in development/preview environments.\n' +
|
||||
'Ensure VITE_ALLOW_CAPTCHA_BYPASS=false in production!'
|
||||
);
|
||||
}
|
||||
}, [bypassEnabled]);
|
||||
@@ -28,7 +19,5 @@ export function useCaptchaBypass() {
|
||||
return {
|
||||
bypassEnabled,
|
||||
requireCaptcha: !bypassEnabled,
|
||||
environmentAllowsBypass,
|
||||
adminEnabledBypass
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user