Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/src/node/routes/logout.ts

15 lines
567 B
TypeScript
Raw Normal View History

2021-05-03 21:22:29 +02:00
import { Router } from "express"
import { CookieKeys } from "../../common/http"
import { getCookieOptions, redirect } from "../http"
import { sanitizeString } from "../util"
2021-05-03 21:22:29 +02:00
export const router = Router()
router.get<{}, undefined, undefined, { base?: string; to?: string }>("/", async (req, res) => {
2021-05-03 21:22:29 +02:00
// Must use the *identical* properties used to set the cookie.
res.clearCookie(CookieKeys.Session, getCookieOptions(req))
2021-05-03 21:22:29 +02:00
const to = sanitizeString(req.query.to) || "/"
return redirect(req, res, to, { to: undefined, base: undefined, href: undefined })
2021-05-03 21:22:29 +02:00
})