mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
refactor: auth component
This commit is contained in:
parent
f42cc026ac
commit
9ad5c1f289
@ -11,15 +11,11 @@ type DashboardProps = {
|
|||||||
export default async function MainLayout({ children }: DashboardProps) {
|
export default async function MainLayout({ children }: DashboardProps) {
|
||||||
const session = await auth();
|
const session = await auth();
|
||||||
|
|
||||||
if (!session && getEnv("SitePassword")) {
|
|
||||||
return <SignIn />;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 />
|
||||||
{children}
|
{!session && getEnv("SitePassword") ? <SignIn /> : children}
|
||||||
<Footer />
|
<Footer />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Footer from "@/app/[locale]/(main)/footer";
|
|
||||||
import Header from "@/app/[locale]/(main)/header";
|
|
||||||
import { getCsrfToken } from "next-auth/react";
|
import { getCsrfToken } from "next-auth/react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export function SignIn({}) {
|
export function SignIn() {
|
||||||
const t = useTranslations("SignIn");
|
const t = useTranslations("SignIn");
|
||||||
|
|
||||||
const [csrfToken, setCsrfToken] = useState("");
|
const [csrfToken, setCsrfToken] = useState("");
|
||||||
@ -31,9 +29,6 @@ export function SignIn({}) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<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">
|
|
||||||
<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 "
|
||||||
method="post"
|
method="post"
|
||||||
@ -59,8 +54,5 @@ export function SignIn({}) {
|
|||||||
</button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
<Footer />
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user