This commit is contained in:
s871077
2026-09-11 10:11:09 +08:00
parent e25c995560
commit 58587d19a8
25 changed files with 1643 additions and 54 deletions
+36 -24
View File
@@ -1,44 +1,56 @@
import { auth, signIn, signOut } from "@/auth";
// --- SSO DISABLED FOR CICD TEST ---
// import { auth, signIn, signOut } from "@/auth";
// --- END SSO DISABLED ---
export default async function TopNav() {
const session = await auth();
const user = session?.user;
// --- SSO DISABLED FOR CICD TEST ---
// const session = await auth();
// const user = session?.user;
const user = { name: "CI Test User" };
// --- END SSO DISABLED ---
return (
<header className="flex h-14 items-center justify-between bg-[#111827] px-6 text-white">
<span className="text-lg font-semibold">Global IT Cost Dashboard</span>
{user ? (
<div className="flex items-center gap-3">
<span className="text-sm text-white/80">{user.name ?? user.email}</span>
{/* --- SSO DISABLED FOR CICD TEST ---
Original: `{user ? (<logged-in block/>) : (<login form/>)}`. Both forms
are server actions calling signOut/signIn, which would throw without
the Entra env vars, so only the name is rendered below.
<div className="flex items-center gap-3">
<span className="text-sm text-white/80">{user.name ?? user.email}</span>
<form
action={async () => {
"use server";
await signOut({ redirectTo: "/" });
}}
>
<button
type="submit"
className="rounded-md bg-white/10 px-4 py-1.5 text-sm font-medium hover:bg-white/20"
>
Logout
</button>
</form>
</div>
<form
action={async () => {
"use server";
await signOut({ redirectTo: "/" });
await signIn("microsoft-entra-id");
}}
>
<button
type="submit"
className="rounded-md bg-white/10 px-4 py-1.5 text-sm font-medium hover:bg-white/20"
>
Logout
Login
</button>
</form>
</div>
) : (
<form
action={async () => {
"use server";
await signIn("microsoft-entra-id");
}}
>
<button
type="submit"
className="rounded-md bg-white/10 px-4 py-1.5 text-sm font-medium hover:bg-white/20"
>
Login
</button>
</form>
)}
--- END SSO DISABLED --- */}
<div className="flex items-center gap-3">
<span className="text-sm text-white/80">{user.name}</span>
</div>
</header>
);
}