From 458396f782037fc7893305bb9f0a1b592304e9de Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Sun, 13 Aug 2023 20:06:19 +0100 Subject: [PATCH] Fix cookie not removed --- src/components/Navigation/navigation.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/Navigation/navigation.ts b/src/components/Navigation/navigation.ts index c8557fea9..47f44baa5 100644 --- a/src/components/Navigation/navigation.ts +++ b/src/components/Navigation/navigation.ts @@ -1,8 +1,15 @@ import Cookies from 'js-cookie'; -import { TOKEN_COOKIE_NAME } from "../../lib/jwt"; +import { TOKEN_COOKIE_NAME } from '../../lib/jwt'; export function logout() { Cookies.remove(TOKEN_COOKIE_NAME); + + // @FIXME: fix the domain name in the cookie created by the API + Cookies.remove(TOKEN_COOKIE_NAME, { + path: '/', + domain: 'api.roadmap.sh', + }); + // Reloading will automatically redirect the user if required window.location.reload(); } @@ -36,10 +43,10 @@ function bindEvents() { }); document - .querySelector('[data-command-menu]') - ?.addEventListener('click', () => { - window.dispatchEvent(new CustomEvent('command.k')); - }); + .querySelector('[data-command-menu]') + ?.addEventListener('click', () => { + window.dispatchEvent(new CustomEvent('command.k')); + }); } bindEvents();