[WEB-1319] chore: handled redirection when user is not logged in (#4497)

* chore: handled redirection when user is not logged in

* dev: handle url redirection in space app

* dev: remove user from redis on successful code matching
This commit is contained in:
guru_sainath 2024-05-17 14:27:49 +05:30 committed by GitHub
parent c2e293cf3b
commit 2988d5e429
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 119 additions and 175 deletions

View file

@ -1,4 +1,5 @@
"use client";
import { observer } from "mobx-react-lite";
import useSWR from "swr";
// components
@ -9,17 +10,18 @@ import { AuthView } from "@/components/views";
import { useUser } from "@/hooks/store";
function HomePage() {
const { fetchCurrentUser, isAuthenticated, isLoading } = useUser();
const { data: currentUser, fetchCurrentUser, isAuthenticated, isLoading } = useUser();
useSWR("CURRENT_USER", () => fetchCurrentUser(), { errorRetryCount: 0 });
useSWR("CURRENT_USER", () => fetchCurrentUser(), {
errorRetryCount: 0,
revalidateIfStale: false,
revalidateOnFocus: false,
refreshWhenHidden: false,
});
if (isLoading) {
return <LogoSpinner />;
}
if (isLoading) return <LogoSpinner />;
if (isAuthenticated) {
return <UserLoggedIn />;
}
if (currentUser && isAuthenticated) return <UserLoggedIn />;
return <AuthView />;
}