From 90f953a168a3dfdbc86a75b6e7daafca9e5c914e Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 21 Oct 2024 09:25:22 +0800 Subject: [PATCH] fix: auth error --- components/sign-in.tsx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/components/sign-in.tsx b/components/sign-in.tsx index e16ccc3..051637b 100644 --- a/components/sign-in.tsx +++ b/components/sign-in.tsx @@ -1,22 +1,22 @@ +"use client" + import Footer from "@/app/[locale]/(main)/footer"; import Header from "@/app/[locale]/(main)/header"; -import { signIn } from "@/auth"; -import { useLocale } from "next-intl"; -import { redirect } from "next/navigation"; -export const runtime = 'edge'; +import { getCsrfToken } from "next-auth/react" +import { useEffect, useState } from "react"; export function SignIn() { - const locale = useLocale(); + const [csrfToken, setCsrfToken] = useState("") - async function handleSubmit(formData: FormData) { - "use server"; - try { - await signIn("credentials", formData); - } catch (error) { - redirect(`/${locale}`); + useEffect(() => { + async function loadProviders() { + const csrf = await getCsrfToken() + setCsrfToken(csrf) } - } + loadProviders() + }, []) + return (
@@ -24,8 +24,10 @@ export function SignIn() {
+