Skip to content

Commit

Permalink
fix: reloads on organization switch
Browse files Browse the repository at this point in the history
  • Loading branch information
panvourtsis committed Aug 31, 2023
1 parent f85dca8 commit dff5a2d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/authentication/Authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const AuthenticationWrapper: React.FunctionComponent = ({ children }) => {
}
})();
}
}, [getAccessTokenSilently, selectedOrganization?.org_id]);
// @NOTE selectedOrganization?.org_id, isLoading, systemLoading
// are missing on purpose from the deps as these are being updated from places where the organization id is being handled with refresh from auth0
}, [getAccessTokenSilently, loginWithRedirect, setOrganizations, setSelectedOrganization]);

// when loading is true before navigation this is not showing anymore
if (systemLoading === undefined || systemLoading || isLoading || !isAuthenticated) {
Expand Down
1 change: 1 addition & 0 deletions src/authentication/components/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const TopBar: React.FC<TopBarProps> = memo(
const foundOrg = organizations.find((org) => org.display_name === option);
if (foundOrg) {
const client = await getAuth0Client();
await client.logout({ openUrl: false });
await client.loginWithRedirect({
authorizationParams: {
organization: foundOrg.org_id,
Expand Down
1 change: 1 addition & 0 deletions src/authentication/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const providerConfig: Auth0ClientOptions = {
},
useRefreshTokens: true,
cacheLocation: 'localstorage',
useRefreshTokensFallback: true, // fix issue with logout https://community.auth0.com/t/auth0-spa-2-x-returning-missing-refresh-token/98999/18
};

export const defaultContextValues: AuthenticationContextProps = {
Expand Down

0 comments on commit dff5a2d

Please sign in to comment.