From 252c552771a5b61f16e7a5e23b30d270fd820a93 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 21 Jun 2023 02:17:23 -0400 Subject: [PATCH] fix(striker-ui-api): clear cookies on logout --- .../src/lib/request_handlers/auth/logout.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/auth/logout.ts b/striker-ui-api/src/lib/request_handlers/auth/logout.ts index c6b28e24..a022059d 100644 --- a/striker-ui-api/src/lib/request_handlers/auth/logout.ts +++ b/striker-ui-api/src/lib/request_handlers/auth/logout.ts @@ -1,17 +1,19 @@ import { RequestHandler } from 'express'; +import { cname } from '../../cname'; import { stdout } from '../../shell'; export const logout: RequestHandler = (request, response) => { request.session.destroy((error) => { - let scode = 204; - if (error) { - scode = 500; - stdout(`Failed to destroy session upon logout; CAUSE: ${error}`); + + return response.status(500).send(); } - response.status(scode).send(); + response.clearCookie(cname('user')); + response.clearCookie(cname('sid')); + + return response.status(204).send(); }); };