File
Blob: src/worker/api/public/auth.ts
| 1 | import { clearSessionCookie, readSessionCookie } from "@/worker/auth/cookies"; |
| 2 | import { deleteSession } from "@/worker/auth/sessions"; |
| 3 | import type { AppContext } from "@/worker/hono"; |
| 4 | |
| 5 | export const handleLogout = async (c: AppContext): Promise<Response> => { |
| 6 | const sessionId = readSessionCookie(c); |
| 7 | |
| 8 | if (sessionId) { |
| 9 | await deleteSession(c.env, sessionId); |
| 10 | } |
| 11 | |
| 12 | clearSessionCookie(c); |
| 13 | return c.body(null, 204); |
| 14 | }; |