13 lines · 460 BRaw
| 1 | import { redirect } from "react-router"; |
| 2 | import type { Route } from "./+types/logout"; |
| 3 | import { clearedSessionCookie, gate, sessionToken } from "../lib/session"; |
| 4 | |
| 5 | export async function action({ request, context }: Route.ActionArgs) { |
| 6 | const token = sessionToken(request); |
| 7 | if (token) await gate(context).signOut(token); |
| 8 | throw redirect("/login", { headers: { "Set-Cookie": clearedSessionCookie() } }); |
| 9 | } |
| 10 | |
| 11 | export function loader() { |
| 12 | throw redirect("/"); |
| 13 | } |