[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:
parent
c2e293cf3b
commit
2988d5e429
14 changed files with 119 additions and 175 deletions
|
|
@ -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 />;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue