@@ -12,6 +12,8 @@ import { formatPhoneNumber, normalizePhoneNumber } from "../../utils/phoneNumber
1212import { evaluatePasswordStrength } from "../../utils/passwordSecurity" ;
1313import "./Register.css" ;
1414
15+ const TURNSTILE_TEST_SITE_KEY = "1x00000000000000000000AA" ;
16+
1517export default function Register ( ) {
1618 const [ displayName , setDisplayName ] = useState ( "" ) ;
1719 const [ email , setEmail ] = useState ( "" ) ;
@@ -29,7 +31,8 @@ export default function Register() {
2931 const navigate = useNavigate ( ) ;
3032 const location = useLocation ( ) ;
3133 const from = ( location . state as { from ?: string } ) ?. from || "/" ;
32- const turnstileSiteKey = import . meta. env . VITE_TURNSTILE_SITE_KEY ?. trim ( ) ?? "" ;
34+ const configuredTurnstileSiteKey = import . meta. env . VITE_TURNSTILE_SITE_KEY ?. trim ( ) ?? "" ;
35+ const turnstileSiteKey = configuredTurnstileSiteKey || ( import . meta. env . DEV ? TURNSTILE_TEST_SITE_KEY : "" ) ;
3336
3437 const displayError = localError || authError ;
3538 const passwordStrength = useMemo ( ( ) => evaluatePasswordStrength ( password ) , [ password ] ) ;
@@ -61,6 +64,7 @@ export default function Register() {
6164 const toggleConfirmLabel = showConfirmPassword ? "Hide confirm password" : "Show confirm password" ;
6265 const isTurnstileReady = Boolean ( turnstileSiteKey ) ;
6366 const isTurnstileVerified = Boolean ( turnstileToken ) ;
67+ const usingTurnstileTestKey = ! configuredTurnstileSiteKey && turnstileSiteKey === TURNSTILE_TEST_SITE_KEY ;
6468
6569 const handleTurnstileSuccess = useCallback ( ( token : string ) => {
6670 setTurnstileToken ( token ) ;
@@ -107,7 +111,7 @@ export default function Register() {
107111 }
108112
109113 if ( ! isTurnstileReady ) {
110- setLocalError ( "Turnstile site key missing. Add VITE_TURNSTILE_SITE_KEY to your .env file ." ) ;
114+ setLocalError ( "Turnstile site key missing. Add VITE_TURNSTILE_SITE_KEY to your environment configuration ." ) ;
111115 return ;
112116 }
113117
@@ -277,15 +281,23 @@ export default function Register() {
277281 </ p >
278282
279283 { isTurnstileReady ? (
280- < TurnstileWidget
281- siteKey = { turnstileSiteKey }
282- onSuccess = { handleTurnstileSuccess }
283- onExpire = { handleTurnstileExpire }
284- onError = { handleTurnstileError }
285- />
284+ < >
285+ < TurnstileWidget
286+ siteKey = { turnstileSiteKey }
287+ onSuccess = { handleTurnstileSuccess }
288+ onExpire = { handleTurnstileExpire }
289+ onError = { handleTurnstileError }
290+ />
291+ { usingTurnstileTestKey ? (
292+ < p className = "auth-turnstile-missing" >
293+ Using Cloudflare's test Turnstile key for local development. Add{ " " }
294+ < code > VITE_TURNSTILE_SITE_KEY</ code > to your environment configuration before deploying.
295+ </ p >
296+ ) : null }
297+ </ >
286298 ) : (
287299 < p className = "auth-turnstile-missing" >
288- Turnstile is not configured yet. Add < code > VITE_TURNSTILE_SITE_KEY</ code > to your < code > .env </ code > file .
300+ Turnstile is not configured yet. Add < code > VITE_TURNSTILE_SITE_KEY</ code > to your environment configuration .
289301 </ p >
290302 ) }
291303
0 commit comments