Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed broken logout

Blue Mouseb65cc540153a
diff --git a/src/utils/accessToken.js b/src/utils/accessToken.js
index aa74cb322..517e9b4d1 100644
--- a/src/utils/accessToken.js
+++ b/src/utils/accessToken.js
@@ -1,6 +1,6 @@
import _isEmpty from 'lodash/isEmpty'
import { TOKEN } from 'redux/constants'
-import { getCookie, setCookie } from './cookie'
+import { getCookie, setCookie, deleteCookie } from './cookie'
// 14 weeks in seconds
const STORE_AUTH_TOKEN_FOR = 8467200
@@ -26,6 +26,6 @@ export const setAccessToken = (token, temporary = false) => {
}
export const removeAccessToken = () => {
- setCookie(TOKEN, '', 0)
+ deleteCookie(TOKEN)
sessionStorage.removeItem(TOKEN)
}
diff --git a/src/utils/cookie.js b/src/utils/cookie.js
index 59dad2eaa..30e923ecd 100644
--- a/src/utils/cookie.js
+++ b/src/utils/cookie.js
@@ -13,3 +13,7 @@ export const getCookie = key => {
export const setCookie = (key, value, maxAge = 3600, sameSite = 'strict') => {
document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; domain=${COOKIE_DOMAIN} SameSite=${sameSite}; secure`
}
+
+export const deleteCookie = (key) => {
+ document.cookie = `${key}=; max-age=0; path=/; SameSite=strict`
+}
diff --git a/src/utils/refreshToken.js b/src/utils/refreshToken.js
index 4a233f796..d5613375a 100644
--- a/src/utils/refreshToken.js
+++ b/src/utils/refreshToken.js
@@ -1,5 +1,5 @@
import { REFRESH_TOKEN } from 'redux/constants'
-import { getCookie, setCookie } from './cookie'
+import { getCookie, setCookie, deleteCookie } from './cookie'
// 14 weeks in seconds
const STORE_REFRESH_TOKEN_FOR = 8467200
@@ -13,5 +13,5 @@ export const setRefreshToken = (token) => {
}
export const removeRefreshToken = () => {
- setCookie(REFRESH_TOKEN, '', 0)
+ deleteCookie(REFRESH_TOKEN)
}