fix(auth): clear query cache when user logs out from nav menu
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user