add sessionDestroy func

This commit is contained in:
HorizonCode 2023-05-13 06:25:28 +02:00
parent 5392b032d0
commit 96a73035f8
2 changed files with 5 additions and 1 deletions

View File

@ -82,7 +82,7 @@ httpServer.get("/site", (_req, rep) => {
httpServer.delete("/session", (req, _rep) => { httpServer.delete("/session", (req, _rep) => {
const username = req.session.user as string ?? ""; const username = req.session.user as string ?? "";
if (username.length > 0) { if (username.length > 0) {
delete req.session.user; req.sessionDestroy();
return { return {
code: 200, code: 200,
message: "Logged out!", message: "Logged out!",

4
mod.ts
View File

@ -448,6 +448,10 @@ export class RouteRequest {
} }
} }
sessionDestroy(): void {
this.session = {};
}
header(name: string): unknown { header(name: string): unknown {
const matchingHeader = Array.from(this.headers.keys()).find((headerName) => const matchingHeader = Array.from(this.headers.keys()).find((headerName) =>
headerName === name headerName === name