Force immediate redirect when no user, don't wait for loading

cgen-3aedfef317d043e8abcacda51949333a
This commit is contained in:
Builder.io 2025-08-08 10:17:39 +00:00
parent 18e3c2edc2
commit 8bf8ac94a2

View file

@ -55,15 +55,16 @@ export default function Dashboard() {
});
useEffect(() => {
if (!authLoading && !user) {
// Force redirect immediately if no user
if (!user) {
setIsLoading(false);
navigate("/login");
navigate("/login", { replace: true });
return;
}
if (user && profile) {
loadDashboardData();
} else if (!authLoading) {
} else if (user && !profile && !authLoading) {
setIsLoading(false);
}
}, [user, profile, authLoading, navigate]);