turn on SSO

This commit is contained in:
s871077
2026-09-21 18:42:32 +08:00
parent 137a4a2a39
commit 167eb0807d
12 changed files with 97 additions and 102 deletions
+24 -36
View File
@@ -1,56 +1,44 @@
// --- SSO DISABLED FOR CICD TEST ---
// import { auth, signIn, signOut } from "@/auth";
// --- END SSO DISABLED ---
import { auth, signIn, signOut } from "@/auth";
export default async function TopNav() {
// --- SSO DISABLED FOR CICD TEST ---
// const session = await auth();
// const user = session?.user;
const user = { name: "CI Test User" };
// --- END SSO DISABLED ---
const session = await auth();
const user = session?.user;
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>
{/* --- 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>
{user ? (
<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 signIn("microsoft-entra-id");
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"
>
Login
Logout
</button>
</form>
--- END SSO DISABLED --- */}
<div className="flex items-center gap-3">
<span className="text-sm text-white/80">{user.name}</span>
</div>
</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>
)}
</header>
);
}