test: auth page

This commit is contained in:
hamster1963 2024-10-21 01:27:46 +08:00
parent bf60403111
commit 01ab91976d

View File

@ -1,16 +1,18 @@
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 { auth } from "@/auth"; import { auth } from "@/auth";
import { SignIn } from "@/components/sign-in";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import React from "react"; import React from "react";
import { redirect } from "next/navigation";
type DashboardProps = { type DashboardProps = {
children: React.ReactNode; children: React.ReactNode;
}; };
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("SITE_PASSWORD")) return <SignIn /> if (!session && getEnv("SITE_PASSWORD")) {
redirect("/api/auth/signin");
}
return ( return (
<div className="flex min-h-screen w-full flex-col"> <div className="flex min-h-screen w-full flex-col">