feat(auth): sign out from the app header

The shell had no way to end a session on shared booth machines; the new
button signs out and returns to the login page.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-21 00:45:36 +00:00
parent 8601a6014f
commit 2fc71883d7
3 changed files with 54 additions and 0 deletions
+2
View File
@@ -1,5 +1,6 @@
import type { SystemRole } from "@/auth/roles";
import { NavTabs, NavRail } from "./nav";
import { SignOutButton } from "./sign-out-button";
/**
* App shell: sticky header (app title + mobile tab bar), desktop side rail,
@@ -28,6 +29,7 @@ export function AppLayout({
<span className="ml-auto hidden text-xs text-muted-foreground sm:block">
Glenloch Baptist Church
</span>
<SignOutButton />
</div>
<NavTabs className="md:hidden" role={role} />
</header>
+39
View File
@@ -0,0 +1,39 @@
"use client";
import { useState } from "react";
import { signOut } from "next-auth/react";
import { LogOut } from "lucide-react";
import { Button } from "@/components/ui/button";
/**
* Ends the Auth.js session and returns to the login page. Lives in the app
* header so it is reachable from every authenticated screen, on mobile and
* desktop alike.
*/
export function SignOutButton() {
const [busy, setBusy] = useState(false);
async function onSignOut() {
setBusy(true);
try {
await signOut({ callbackUrl: "/login" });
} finally {
setBusy(false);
}
}
return (
<Button
type="button"
variant="ghost"
size="sm"
onClick={onSignOut}
disabled={busy}
aria-label="Sign out"
className="gap-2"
>
<LogOut className="h-4 w-4" aria-hidden="true" />
<span className="hidden sm:inline">{busy ? "Signing out…" : "Sign out"}</span>
</Button>
);
}