Skip to content

Commit

Permalink
🐛 fix(turnstile): Turnstile_site_key
Browse files Browse the repository at this point in the history
  • Loading branch information
web-ppanel committed Dec 7, 2024
1 parent 34e24b8 commit 0327b73
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apps/admin/app/(auth)/user-login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useForm } from '@shadcn/ui/lib/react-hook-form';
import { z, zodResolver } from '@shadcn/ui/lib/zod';
import { useTranslations } from 'next-intl';
import { Dispatch, SetStateAction } from 'react';

import CloudFlareTurnstile from './turnstile';

export default function UserLoginForm({
Expand All @@ -30,7 +29,8 @@ export default function UserLoginForm({
const formSchema = z.object({
email: z.string(),
password: z.string(),
cf_token: verify.enable_login_verify ? z.string() : z.string().optional(),
cf_token:
verify.enable_login_verify && verify.turnstile_site_key ? z.string() : z.string().optional(),
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down
6 changes: 4 additions & 2 deletions apps/admin/app/(auth)/user-register-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { z, zodResolver } from '@shadcn/ui/lib/zod';
import { useCountDown } from 'ahooks';
import { useTranslations } from 'next-intl';
import { Dispatch, SetStateAction, useState } from 'react';

import CloudFlareTurnstile from './turnstile';

export default function UserRegisterForm({
Expand Down Expand Up @@ -52,7 +51,10 @@ export default function UserRegisterForm({
repeat_password: z.string(),
code: register.enable_email_verify ? z.string() : z.string().nullish(),
invite: invite.forced_invite ? z.string() : z.string().nullish(),
cf_token: verify.enable_register_verify ? z.string() : z.string().nullish(),
cf_token:
verify.enable_register_verify && verify.turnstile_site_key
? z.string()
: z.string().nullish(),
})
.superRefine(({ password, repeat_password }, ctx) => {
if (password !== repeat_password) {
Expand Down
6 changes: 4 additions & 2 deletions apps/admin/app/(auth)/user-reset-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { z, zodResolver } from '@shadcn/ui/lib/zod';
import { useCountDown } from 'ahooks';
import { useTranslations } from 'next-intl';
import { Dispatch, SetStateAction, useState } from 'react';

import CloudFlareTurnstile from './turnstile';

export default function UserResetForm({
Expand Down Expand Up @@ -49,7 +48,10 @@ export default function UserResetForm({
email: z.string(),
password: z.string(),
code: register.enable_email_verify ? z.string() : z.string().nullish(),
cf_token: verify.enable_register_verify ? z.string() : z.string().nullish(),
cf_token:
verify.enable_register_verify && verify.turnstile_site_key
? z.string()
: z.string().nullish(),
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down
3 changes: 2 additions & 1 deletion apps/user/app/auth/user-login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default function UserLoginForm({
const formSchema = z.object({
email: z.string(),
password: z.string(),
cf_token: verify.enable_login_verify ? z.string() : z.string().optional(),
cf_token:
verify.enable_login_verify && verify.turnstile_site_key ? z.string() : z.string().optional(),
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down
5 changes: 4 additions & 1 deletion apps/user/app/auth/user-register-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default function UserRegisterForm({
repeat_password: z.string(),
code: register.enable_email_verify ? z.string() : z.string().nullish(),
invite: invite.forced_invite ? z.string() : z.string().nullish(),
cf_token: verify.enable_register_verify ? z.string() : z.string().nullish(),
cf_token:
verify.enable_register_verify && verify.turnstile_site_key
? z.string()
: z.string().nullish(),
})
.superRefine(({ password, repeat_password }, ctx) => {
if (password !== repeat_password) {
Expand Down
6 changes: 4 additions & 2 deletions apps/user/app/auth/user-reset-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { z, zodResolver } from '@shadcn/ui/lib/zod';
import { useCountDown } from 'ahooks';
import { useTranslations } from 'next-intl';
import { Dispatch, SetStateAction, useState } from 'react';

import CloudFlareTurnstile from './turnstile';

export default function UserResetForm({
Expand Down Expand Up @@ -49,7 +48,10 @@ export default function UserResetForm({
email: z.string(),
password: z.string(),
code: register.enable_email_verify ? z.string() : z.string().nullish(),
cf_token: verify.enable_register_verify ? z.string() : z.string().nullish(),
cf_token:
verify.enable_register_verify && verify.turnstile_site_key
? z.string()
: z.string().nullish(),
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand Down

0 comments on commit 0327b73

Please sign in to comment.