Skip to content

Commit

Permalink
better comments and easier boolean logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dudiiiiiiii committed Oct 17, 2024
1 parent 2413a68 commit 377f820
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/services/AuthService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,20 @@ const Auth = ({ children }: GenericContextProviderProps) => {
);
};

if (!initialized || !keycloak.authenticated) {
if (initialized && !keycloak.authenticated) {
if (!initialized) {
// keycloak authentication system not initilized (working in demo mode or keycloak not to handle authentication and authorization)
// skipping futher checks (for example: to ask backend if the keycloak token is OK
return;
} else {
// keycloak authentication is initilized, so it makes sense to check if user is authenticated in keycloak
if (!keycloak.authenticated) {
// user not authenticated, forcing logout from yaptide app
logout();
}

return;
// skipping futher checks (for example: to ask backend if the keycloak token is OK
return;
}
// user authenticated, we proceed with further checks
}

checkPlgridAccessServices(keycloak.tokenParsed)
Expand Down

0 comments on commit 377f820

Please sign in to comment.