diff --git a/e2e/shell.spec.ts b/e2e/shell.spec.ts
index 3ea871d..0b15f1a 100644
--- a/e2e/shell.spec.ts
+++ b/e2e/shell.spec.ts
@@ -55,6 +55,19 @@ test.describe("app shell", () => {
);
});
+ test("signs out and locks the shell again", async ({ page }) => {
+ await page.setViewportSize({ width: 1024, height: 768 });
+ await signInAs(page, `e2e-signout-${Date.now()}@example.com`);
+
+ await page.goto(`${BASE}/home`);
+ await page.getByRole("button", { name: "Sign out" }).click();
+ await expect(page).toHaveURL(`${BASE}/login`);
+
+ // The session cookie is gone, so the guarded shell bounces back to login.
+ await page.goto(`${BASE}/home`);
+ await expect(page).toHaveURL(`${BASE}/login`);
+ });
+
test("redirects unauthenticated users away from the shell", async ({ page }) => {
await page.setViewportSize({ width: 360, height: 780 });
await page.goto(`${BASE}/schedule`);
diff --git a/src/components/app/app-layout.tsx b/src/components/app/app-layout.tsx
index e754c49..348bd2d 100644
--- a/src/components/app/app-layout.tsx
+++ b/src/components/app/app-layout.tsx
@@ -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({
Glenloch Baptist Church
+
diff --git a/src/components/app/sign-out-button.tsx b/src/components/app/sign-out-button.tsx
new file mode 100644
index 0000000..c3c2d73
--- /dev/null
+++ b/src/components/app/sign-out-button.tsx
@@ -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 (
+
+ );
+}