g1t/apps/web/app/routes/logout.tsx
| 1 | import { redirect } from "react-router"; |
| 2 | |
| 3 | import type { Route } from "./+types/logout"; |
| 4 | import { assertSameOrigin, endSession, nextPath } from "../lib/session.server"; |
| 5 | |
| 6 | /** |
| 7 | * Signs out, then goes home, or to `next` (a path on g1t only): "Switch |
| 8 | * account" signs out to the sign-in page, which brings them back. |
| 9 | */ |
| 10 | export async function action({ request }: Route.ActionArgs) { |
| 11 | assertSameOrigin(request); |
| 12 | throw redirect(nextPath(request), { |
| 13 | headers: { "set-cookie": await endSession(request) }, |
| 14 | }); |
| 15 | } |
| 16 | |
| 17 | export function loader() { |
| 18 | throw redirect("/"); |
| 19 | } |