mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-10 15:47:59 -05:00
update(turnstile): Add env to hide turnstile for dev deploy (#10116)
This simply adds a env to hide turnstile for dev deploys if this env ``NEXT_PUBLIC_DISABLE_TURNSTILE`` is set to false which it is by default, it will show turnstile, if the env is set to "true" it will hide the turnstile #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Login/register with ``NEXT_PUBLIC_DISABLE_TURNSTILE=false`` and you see the turnstile and that is needed to login/signup - [x] Login/register with ``NEXT_PUBLIC_DISABLE_TURNSTILE=true`` and you will see the turnstile is gone, and you can login/signup with out it
This commit is contained in:
@@ -30,3 +30,4 @@ NEXT_PUBLIC_SHOW_BILLING_PAGE=false
|
||||
## Get these from the Cloudflare Turnstile dashboard: https://dash.cloudflare.com/?to=/:account/turnstile
|
||||
## This is the frontend site key
|
||||
NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY=
|
||||
NEXT_PUBLIC_DISABLE_TURNSTILE=false
|
||||
|
||||
@@ -47,10 +47,13 @@ export function useTurnstile({
|
||||
useEffect(() => {
|
||||
const behaveAs = getBehaveAs();
|
||||
const hasTurnstileKey = !!TURNSTILE_SITE_KEY;
|
||||
const turnstileDisabled = process.env.NEXT_PUBLIC_DISABLE_TURNSTILE === "true";
|
||||
|
||||
setShouldRender(behaveAs === BehaveAs.CLOUD && hasTurnstileKey);
|
||||
// Only render Turnstile in cloud environment if not explicitly disabled
|
||||
setShouldRender(behaveAs === BehaveAs.CLOUD && hasTurnstileKey && !turnstileDisabled);
|
||||
|
||||
if (behaveAs !== BehaveAs.CLOUD || !hasTurnstileKey) {
|
||||
// Skip verification if disabled, in local development, or no key
|
||||
if (turnstileDisabled || behaveAs !== BehaveAs.CLOUD || !hasTurnstileKey) {
|
||||
setVerified(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -7,6 +7,11 @@ export async function verifyTurnstileToken(
|
||||
token: string,
|
||||
action?: string,
|
||||
): Promise<boolean> {
|
||||
// Skip verification if explicitly disabled via environment variable
|
||||
if (process.env.NEXT_PUBLIC_DISABLE_TURNSTILE === "true") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip verification in local development
|
||||
const behaveAs = getBehaveAs();
|
||||
if (behaveAs !== BehaveAs.CLOUD) {
|
||||
|
||||
Reference in New Issue
Block a user