mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: auth error
This commit is contained in:
parent
c131efd6dc
commit
90f953a168
@ -1,22 +1,22 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
import Footer from "@/app/[locale]/(main)/footer";
|
import Footer from "@/app/[locale]/(main)/footer";
|
||||||
import Header from "@/app/[locale]/(main)/header";
|
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() {
|
export function SignIn() {
|
||||||
const locale = useLocale();
|
const [csrfToken, setCsrfToken] = useState("")
|
||||||
|
|
||||||
async function handleSubmit(formData: FormData) {
|
useEffect(() => {
|
||||||
"use server";
|
async function loadProviders() {
|
||||||
try {
|
const csrf = await getCsrfToken()
|
||||||
await signIn("credentials", formData);
|
setCsrfToken(csrf)
|
||||||
} catch (error) {
|
|
||||||
redirect(`/${locale}`);
|
|
||||||
}
|
}
|
||||||
}
|
loadProviders()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen w-full flex-col">
|
<div className="flex min-h-screen w-full flex-col">
|
||||||
@ -24,8 +24,10 @@ export function SignIn() {
|
|||||||
<Header />
|
<Header />
|
||||||
<form
|
<form
|
||||||
className="flex flex-col items-center justify-start gap-4 p-4 "
|
className="flex flex-col items-center justify-start gap-4 p-4 "
|
||||||
action={handleSubmit}
|
method="post"
|
||||||
|
action="/api/auth/callback/credentials"
|
||||||
>
|
>
|
||||||
|
<input type="hidden" name="csrfToken" value={csrfToken} />
|
||||||
<section className="flex flex-col items-start gap-2">
|
<section className="flex flex-col items-start gap-2">
|
||||||
<label className="flex flex-col items-start gap-1 ">
|
<label className="flex flex-col items-start gap-1 ">
|
||||||
<p className="text-base font-semibold">请输入页面密码</p>
|
<p className="text-base font-semibold">请输入页面密码</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user