feat: redirect to same url on login/logout

This commit is contained in:
2023-08-09 15:58:36 +02:00
parent f066b4e5e4
commit 7a5f43d799
5 changed files with 46 additions and 16 deletions

View File

@ -2,9 +2,14 @@ import { deleteCookie } from "https://deno.land/std@0.197.0/http/cookie.ts";
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
GET() {
GET(req) {
const url = new URL(req.url);
const redirect = decodeURIComponent(url.searchParams.get("redirect") || "");
const headers = new Headers();
headers.append("location", "/");
headers.append("location", redirect || "/");
deleteCookie(headers, "session_cookie", {
path: "/",
});