Compare commits

..

No commits in common. "56d28c1ec1aaa6e2cc23100214e248647b25981a" and "a8cbf9589a56df3674f669d9ae55b2ac46bbd9b3" have entirely different histories.

7 changed files with 21 additions and 37 deletions

View File

@ -8,24 +8,16 @@ import React from "react";
type DashboardProps = {
children: React.ReactNode;
};
export default function MainLayout({ children }: DashboardProps) {
export default async function MainLayout({ children }: DashboardProps) {
const session = await auth();
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-background p-4 md:p-10 md:pt-8">
<Header />
<AuthProtected>{children}</AuthProtected>
{!session && getEnv("SitePassword") ? <SignIn /> : children}
<Footer />
</main>
</div>
);
}
async function AuthProtected({ children }: DashboardProps) {
if (getEnv("SitePassword")) {
const session = await auth();
if (!session) {
return <SignIn />;
}
}
return children;
}

View File

@ -12,11 +12,10 @@ interface ResError extends Error {
}
export async function GET(req: NextRequest) {
if (getEnv("SitePassword")) {
const session = await auth();
if (!session) {
redirect("/");
}
const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/");
}
const { searchParams } = new URL(req.url);

View File

@ -12,16 +12,14 @@ interface ResError extends Error {
}
export async function GET(req: NextRequest) {
if (getEnv("SitePassword")) {
const session = await auth();
if (!session) {
redirect("/");
}
const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/");
}
const { searchParams } = new URL(req.url);
const server_id = searchParams.get("server_id");
if (!server_id) {
return NextResponse.json(
{ error: "server_id is required" },

View File

@ -12,11 +12,10 @@ interface ResError extends Error {
}
export async function GET() {
if (getEnv("SitePassword")) {
const session = await auth();
if (!session) {
redirect("/");
}
const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/");
}
try {

View File

@ -48,7 +48,7 @@ export default async function LocaleLayout({
return (
<html lang={locale} suppressHydrationWarning>
<head>
{!process.env.VERCEL && <PublicEnvScript />}
<PublicEnvScript />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css"

View File

@ -1,12 +1,8 @@
import { env } from "next-runtime-env";
export default function getEnv(key: string) {
if (process.env.VERCEL) {
return process.env[key];
} else {
if (key.startsWith("NEXT_PUBLIC_")) {
return env(key);
}
return process.env[key];
if (key.startsWith("NEXT_PUBLIC_")) {
return env(key);
}
return process.env[key];
}

View File

@ -1,6 +1,6 @@
{
"name": "nezha-dash",
"version": "1.2.5",
"version": "1.2.4",
"private": true,
"scripts": {
"dev": "next dev -p 3020",