mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: login state
This commit is contained in:
parent
aff62d55dc
commit
27d61f6174
@ -1,19 +1,25 @@
|
|||||||
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 { signIn } from "@/auth"
|
||||||
|
import { redirect } from "next/navigation"
|
||||||
|
|
||||||
export function SignIn() {
|
export function SignIn() {
|
||||||
|
async function handleSubmit(formData: FormData) {
|
||||||
|
'use server'
|
||||||
|
try {
|
||||||
|
await signIn("credentials", formData)
|
||||||
|
} catch (error) {
|
||||||
|
redirect('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen w-full flex-col">
|
<div className="flex min-h-screen w-full flex-col">
|
||||||
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:p-10 md:pt-8">
|
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:p-10 md:pt-8">
|
||||||
<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={async (formData) => {
|
action={handleSubmit}
|
||||||
"use server"
|
|
||||||
const res = await signIn("credentials", formData)
|
|
||||||
console.log(res)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<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 ">
|
||||||
|
Loading…
Reference in New Issue
Block a user