2fc71883d7
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>
40 lines
945 B
TypeScript
40 lines
945 B
TypeScript
"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>
|
|
);
|
|
}
|