fix: refactor logout to use synchronous flow with full page redirect
- Rewrite logout() from async to synchronous to prevent React re-renders with stale state
- Replace router.push('/login') with redirectToLogin() (window.location.replace) in all page auth guards for reliable navigation in Edge/Safari
- Add performFullLogout() helper that clears auth state, feature stores, and localStorage
- Fix persist middleware partialize to return {} when not authenticated, preventing state resurrection
- Use keepalive fetch for background cookie/token cleanup so redirect fires immediately
- Remove unused useRouter imports from page.tsx and contacts/page.tsx
- Simplify all page logout handlers to directly call logout()
Fixes #63
This commit is contained in:
@@ -101,15 +101,11 @@ export function AccountSwitcher({ variant = "rail", className }: AccountSwitcher
|
||||
const handleLogout = () => {
|
||||
setOpen(false);
|
||||
logout();
|
||||
if (useAccountStore.getState().accounts.length === 0) {
|
||||
router.push("/login" as never);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogoutAll = () => {
|
||||
setOpen(false);
|
||||
logoutAll();
|
||||
router.push("/login" as never);
|
||||
};
|
||||
|
||||
const handleSetDefault = (accountId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user