Archived
1
0

Add logout route

This commit is contained in:
Asher
2021-05-03 14:22:29 -05:00
parent 08ab0afdb0
commit 49c26f70f7
2 changed files with 21 additions and 3 deletions

17
src/node/routes/logout.ts Normal file
View File

@ -0,0 +1,17 @@
import { Router } from "express"
import { getCookieDomain, redirect } from "../http"
import { Cookie } from "./login"
export const router = Router()
router.get("/", async (req, res) => {
// Must use the *identical* properties used to set the cookie.
res.clearCookie(Cookie.Key, {
domain: getCookieDomain(req.headers.host || "", req.args["proxy-domain"]),
path: req.body.base || "/",
sameSite: "lax",
})
const to = (typeof req.query.to === "string" && req.query.to) || "/"
return redirect(req, res, to, { to: undefined, base: undefined })
})