diff --git a/src/components/auth/register-form.tsx b/src/components/auth/register-form.tsx index 66bb123..c00878e 100644 --- a/src/components/auth/register-form.tsx +++ b/src/components/auth/register-form.tsx @@ -15,8 +15,8 @@ import { import { Input } from '@/components/ui/input'; import { websiteConfig } from '@/config/website'; import { authClient } from '@/lib/auth-client'; +import { isTurnstileEnabled, validateTurnstileToken } from '@/lib/captcha'; import { getUrlWithLocaleInCallbackUrl } from '@/lib/urls/urls'; -import { validateTurnstileToken } from '@/lib/validate-captcha'; import { DEFAULT_LOGIN_REDIRECT, Routes } from '@/routes'; import { zodResolver } from '@hookform/resolvers/zod'; import { EyeIcon, EyeOffIcon, Loader2Icon } from 'lucide-react'; @@ -53,7 +53,7 @@ export const RegisterForm = ({ const [showPassword, setShowPassword] = useState(false); // turnstile captcha schema - const turnstileEnabled = websiteConfig.features.enableTurnstileCaptcha; + const turnstileEnabled = isTurnstileEnabled(); const captchaSchema = turnstileEnabled ? z.string().min(1, 'Please complete the captcha') : z.string().optional(); diff --git a/src/components/shared/captcha.tsx b/src/components/shared/captcha.tsx index 3417d3a..ae1ee2b 100644 --- a/src/components/shared/captcha.tsx +++ b/src/components/shared/captcha.tsx @@ -1,7 +1,7 @@ 'use client'; import { FormMessage } from '@/components/ui/form'; -import { websiteConfig } from '@/config/website'; +import { isTurnstileEnabled } from '@/lib/captcha'; import { useLocale } from 'next-intl'; import { useTheme } from 'next-themes'; import dynamic from 'next/dynamic'; @@ -22,11 +22,11 @@ type Props = Omit, 'siteKey'> & { * Captcha component for Cloudflare Turnstile */ export const Captcha = ({ validationError, ...props }: Props) => { - const isTurnstileEnabled = websiteConfig.features.enableTurnstileCaptcha; + const turnstileEnabled = isTurnstileEnabled(); const theme = useTheme(); const locale = useLocale(); - return isTurnstileEnabled ? ( + return turnstileEnabled ? ( <>