fix(auth): clear query cache when user logs out from nav menu

This commit is contained in:
2026-06-23 23:19:09 +05:30
parent dfb95c5213
commit 6e16d4f2c8

View File

@@ -9,6 +9,7 @@ import {
Sparkles,
} from 'lucide-react';
import { useRouter } from 'next/navigation';
import { useQueryClient } from '@tanstack/react-query';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import {
@@ -43,6 +44,7 @@ export function NavUser({
}) {
const { isMobile } = useSidebar();
const router = useRouter();
const queryClient = useQueryClient();
const clearAuth = useAuthStore((state) => state.logout);
const clearApp = useAppStore((state) => state.clear);
const [isLoggingOut, setIsLoggingOut] = useState(false);
@@ -57,6 +59,7 @@ export function NavUser({
} catch {
// Local logout should still complete if the server session is already invalid.
} finally {
queryClient.clear();
clearAuth();
clearApp();
router.replace(ROUTES.LOGIN);