Fixing PLans page
This commit is contained in:
@@ -114,11 +114,22 @@ export const useAuthStore = create<AuthState>()(
|
||||
},
|
||||
|
||||
logout: () => {
|
||||
// Clear cookies (session contamination protection)
|
||||
document.cookie.split(";").forEach((c) => {
|
||||
document.cookie = `${c.split("=")[0].trim()}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;
|
||||
});
|
||||
// CRITICAL: Properly clear ALL cookies to prevent session contamination
|
||||
const cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i];
|
||||
const eqPos = cookie.indexOf("=");
|
||||
const name = eqPos > -1 ? cookie.substr(0, eqPos).trim() : cookie.trim();
|
||||
// Clear cookie for all possible domains and paths
|
||||
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
|
||||
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=" + window.location.hostname;
|
||||
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=." + window.location.hostname;
|
||||
}
|
||||
// Clear all localStorage to prevent state contamination
|
||||
localStorage.clear();
|
||||
// Clear sessionStorage as well
|
||||
sessionStorage.clear();
|
||||
// Reset auth state
|
||||
set({ user: null, token: null, refreshToken: null, isAuthenticated: false, loading: false });
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user