@@ -6,13 +6,15 @@ import AuthInput from './AuthInput';
66import { signupSchema } from '../../types/auth' ;
77import type { SignupFormData } from '../../types/auth' ;
88import { useAuth } from '../../hooks/useAuth' ;
9+ import { useCaptcha } from '../../hooks/useCaptcha' ;
910
1011interface SignupFormProps {
1112 cfCaptchaSiteKey : string ;
1213}
1314
1415export const SignupForm : React . FC < SignupFormProps > = ( { cfCaptchaSiteKey } ) => {
15- const { signup, error : apiError , isLoading } = useAuth ( cfCaptchaSiteKey ) ;
16+ const { signup, error : apiError , isLoading } = useAuth ( ) ;
17+ const { isCaptchaVerified } = useCaptcha ( cfCaptchaSiteKey ) ;
1618 const {
1719 register,
1820 handleSubmit,
@@ -23,6 +25,9 @@ export const SignupForm: React.FC<SignupFormProps> = ({ cfCaptchaSiteKey }) => {
2325
2426 const onSubmit = async ( data : SignupFormData ) => {
2527 try {
28+ if ( ! isCaptchaVerified ) {
29+ throw new Error ( 'Captcha verification failed' ) ;
30+ }
2631 await signup ( data ) ;
2732 } catch ( error ) {
2833 console . error ( error ) ;
@@ -86,10 +91,6 @@ export const SignupForm: React.FC<SignupFormProps> = ({ cfCaptchaSiteKey }) => {
8691 { ...register ( 'confirmPassword' ) }
8792 />
8893
89- < div className = "flex flex-row justify-center" >
90- < div className = "cf-turnstile" data-sitekey = { cfCaptchaSiteKey } data-size = "normal" > </ div >
91- </ div >
92-
9394 < div className = "space-y-2" >
9495 < div className = "flex items-start" >
9596 < div className = "flex items-center h-5" >
0 commit comments