Skip to content

Commit

Permalink
fix: implement logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
xynydev committed Jul 13, 2024
1 parent 0962713 commit dd73079
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
</a>
</DropdownMenu.Item>
<DropdownMenu.Item>
<button on:click={() => alert("unimplemented, just clear cookies")}>
Log out
</button>
<a href="/api/login/logout">Log out</a>
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
Expand Down
11 changes: 11 additions & 0 deletions src/routes/api/login/logout/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// routes/login/github/+server.ts
import { redirect } from "@sveltejs/kit";

import type { RequestEvent } from "@sveltejs/kit";

export async function GET(event: RequestEvent): Promise<Response> {
await event.cookies.delete("github_oauth_state", { path: "/" });
await event.cookies.delete("github_oauth_token", { path: "/" });

redirect(302, "/");
}

0 comments on commit dd73079

Please sign in to comment.