🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
first turnstile locally
Bill Yang151c5412fb39
diff --git a/client/src/app/login/page.tsx b/client/src/app/login/page.tsxindex 95dc44b94..e26ff172d 100644--- a/client/src/app/login/page.tsx+++ b/client/src/app/login/page.tsx@@ -32,8 +32,8 @@ export default function Page() {setError("");- // Validate Turnstile token if in cloud mode- if (IS_CLOUD && !turnstileToken) {+ // Validate Turnstile token if in cloud mode and production+ if (IS_CLOUD && process.env.NODE_ENV === "production" && !turnstileToken) {setError("Please complete the captcha verification");setIsLoading(false);return;@@ -47,7 +47,7 @@ export default function Page() {},{onRequest: context => {- if (IS_CLOUD && turnstileToken) {+ if (IS_CLOUD && process.env.NODE_ENV === "production" && turnstileToken) {context.headers.set("x-captcha-response", turnstileToken);}},@@ -69,6 +69,8 @@ export default function Page() {setIsLoading(false);};+ const turnstileEnabled = IS_CLOUD && process.env.NODE_ENV === "production";+return (<div className="flex flex-col justify-between items-center h-dvh w-full p-4"><div></div>@@ -105,7 +107,7 @@ export default function Page() {}/>- {IS_CLOUD && (+ {turnstileEnabled && (<TurnstileonSuccess={token => setTurnstileToken(token)}onError={() => setTurnstileToken("")}@@ -117,7 +119,7 @@ export default function Page() {<AuthButtonisLoading={isLoading}loadingText="Logging in..."- disabled={IS_CLOUD ? !turnstileToken || isLoading : isLoading}+ disabled={turnstileEnabled ? !turnstileToken || isLoading : isLoading}>Login</AuthButton>diff --git a/client/src/app/reset-password/page.tsx b/client/src/app/reset-password/page.tsxindex 7874a2dd6..c032c6ef7 100644--- a/client/src/app/reset-password/page.tsx+++ b/client/src/app/reset-password/page.tsx@@ -30,8 +30,8 @@ export default function ResetPasswordPage() {setIsLoading(true);setError("");- // Validate Turnstile token if in cloud mode- if (IS_CLOUD && !turnstileToken) {+ // Validate Turnstile token if in cloud mode and production+ if (IS_CLOUD && process.env.NODE_ENV === "production" && !turnstileToken) {setError("Please complete the captcha verification");setIsLoading(false);return;@@ -45,7 +45,7 @@ export default function ResetPasswordPage() {},{onRequest: context => {- if (IS_CLOUD && turnstileToken) {+ if (IS_CLOUD && process.env.NODE_ENV === "production" && turnstileToken) {context.headers.set("x-captcha-response", turnstileToken);}},@@ -181,7 +181,7 @@ export default function ResetPasswordPage() {onChange={e => setEmail(e.target.value)}/>- {IS_CLOUD && (+ {IS_CLOUD && process.env.NODE_ENV === "production" && (<TurnstileonSuccess={token => setTurnstileToken(token)}onError={() => setTurnstileToken("")}@@ -193,7 +193,7 @@ export default function ResetPasswordPage() {<AuthButtonisLoading={isLoading}loadingText="Sending code..."- disabled={IS_CLOUD ? !turnstileToken || isLoading : isLoading}+ disabled={IS_CLOUD && process.env.NODE_ENV === "production" ? !turnstileToken || isLoading : isLoading}>Send Verification Code</AuthButton>diff --git a/server/src/lib/auth.ts b/server/src/lib/auth.tsindex dd50f8afd..c7c0cdde3 100644--- a/server/src/lib/auth.ts+++ b/server/src/lib/auth.ts@@ -83,7 +83,7 @@ const pluginList = [},}),// Add Cloudflare Turnstile captcha (cloud only)- ...(IS_CLOUD && process.env.TURNSTILE_SECRET_KEY+ ...(IS_CLOUD && process.env.TURNSTILE_SECRET_KEY && process.env.NODE_ENV === "production"? [captcha({provider: "cloudflare-turnstile",