Skip to content

Convert Sign-Out API to POST and Implement Form-Based Sign-Out #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/app/_header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ async function ProfileDropdown({ userId }: { userId: UserId }) {
<DropdownMenuLabel>{profile.displayName}</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem asChild className="cursor-pointer">
<Link className="flex items-center" href={"/api/sign-out"}>
<LogOut className="mr-2 h-4 w-4" />
Sign Out
</Link>
<form action="/api/sign-out" method="POST">
<Button type="submit" variant="ghost" className="flex items-center hover:bg-transparent">
<LogOut className="mr-2 h-4 w-4" />
Sign Out
</button>
</form>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/sign-out/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { lucia, validateRequest } from "@/lib/auth";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";

export async function GET(): Promise<Response> {
export async function POST(): Promise<Response> {
await new Promise((resolve) => setTimeout(resolve, 1000));

const { session } = await validateRequest();
Expand Down