From 4f8a19f0158c15176156034739ba638a84158184 Mon Sep 17 00:00:00 2001 From: Douglas Sebastian Date: Fri, 22 Nov 2024 14:53:45 -0300 Subject: [PATCH] refactor: remove finishedLogin state --- src/contexts/Auth/AuthProvider.tsx | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/contexts/Auth/AuthProvider.tsx b/src/contexts/Auth/AuthProvider.tsx index d629687d..52be2c44 100644 --- a/src/contexts/Auth/AuthProvider.tsx +++ b/src/contexts/Auth/AuthProvider.tsx @@ -13,7 +13,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { const [profileLinks, setProfileLinks] = useState([]); const [profileGroups, setProfileGroups] = useState([]); const [organization, setOrganization] = useState>(); - const [finishedLogin, setFinishedLogin] = useState(false); const [isHealthy, setIsHealthy] = useState(); const user = profile?.user ?? null; @@ -60,41 +59,30 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { if (!response.success || response.body === undefined) { goTo("login"); - setFinishedLogin(true); return null; } - setFinishedLogin(false); - const logged = await updateLoggedUser(); - setFinishedLogin(true); - return logged; + return await updateLoggedUser(); } async function signinGoogle() { - setFinishedLogin(false); const profile = await updateLoggedUser(); if (profile === null) { goTo("login"); } - setFinishedLogin(true); return profile; }; async function signout() { - setFinishedLogin(false); - await UniversimeApi.Auth.logout(); await updateLoggedUser(); goTo(""); - - setFinishedLogin(true); }; async function updateLoggedUser() { - setFinishedLogin(false); let profile: Nullable = null; const organization = await updateOrganization(); @@ -109,7 +97,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { setProfile(profile); } - setFinishedLogin(true); return profile; }