fix(auth): sign out - await logout and use full page redirect
- useSidebarNavigation: was not awaiting logout(), so navigate ran before store was updated; LoginPage then saw isAuthenticated=true and redirected back to dashboard - Both Sidebar and Header: use window.location.href instead of navigate() for logout redirect to ensure clean state (clears any stale React/Query cache, forces fresh load)
This commit is contained in:
parent
fa7fc7031e
commit
d6840eda76
2 changed files with 7 additions and 7 deletions
|
|
@ -39,7 +39,8 @@ export function Header(_props: HeaderProps) {
|
|||
const handleLogout = async () => {
|
||||
setIsUserMenuOpen(false);
|
||||
await logout();
|
||||
navigate('/login');
|
||||
// Full page redirect ensures clean state after logout
|
||||
window.location.href = '/login';
|
||||
};
|
||||
|
||||
const toggleTheme = () => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAuthStore } from '@/features/auth/store/authStore';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
|
||||
|
|
@ -12,7 +11,6 @@ const SIDEBAR_BREAKPOINT = 1024;
|
|||
* - Déconnexion
|
||||
*/
|
||||
export function useSidebarNavigation() {
|
||||
const navigate = useNavigate();
|
||||
const { logout } = useAuthStore();
|
||||
const { setSidebarOpen } = useUIStore();
|
||||
|
||||
|
|
@ -22,10 +20,11 @@ export function useSidebarNavigation() {
|
|||
}
|
||||
}, [setSidebarOpen]);
|
||||
|
||||
const handleLogout = useCallback(() => {
|
||||
logout();
|
||||
navigate('/login');
|
||||
}, [logout, navigate]);
|
||||
const handleLogout = useCallback(async () => {
|
||||
await logout();
|
||||
// Full page redirect ensures clean state (clears any stale React/Query cache)
|
||||
window.location.href = '/login';
|
||||
}, [logout]);
|
||||
|
||||
return {
|
||||
handleMobileNav,
|
||||
|
|
|
|||
Loading…
Reference in a new issue