Skip to content

Commit

Permalink
Merge pull request #657 from universi-me/refactor#656/remover-finishe…
Browse files Browse the repository at this point in the history
…dlogin

REFACTOR #656: Remover finishedLogin em AuthProvider
  • Loading branch information
NiiMiyo authored Nov 22, 2024
2 parents 9c4812e + 4f8a19f commit 188d28f
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/contexts/Auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
const [profileLinks, setProfileLinks] = useState<Link[]>([]);
const [profileGroups, setProfileGroups] = useState<Group[]>([]);
const [organization, setOrganization] = useState<Possibly<Group>>();
const [finishedLogin, setFinishedLogin] = useState<boolean>(false);
const [isHealthy, setIsHealthy] = useState<boolean>();
const user = profile?.user ?? null;

Expand Down Expand Up @@ -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<ProfileClass> = null;
const organization = await updateOrganization();

Expand All @@ -109,7 +97,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
setProfile(profile);
}

setFinishedLogin(true);
return profile;
}

Expand Down

0 comments on commit 188d28f

Please sign in to comment.