Skip to content

Commit

Permalink
Fix logout for Che if it's been deployed with nativeUserMode enabled (#…
Browse files Browse the repository at this point in the history
…320)

Co-authored-by: Serhii Leshchenko <[email protected]>
  • Loading branch information
akurinnoy and sleshchenko authored Aug 9, 2021
1 parent cdb3f01 commit e9bac8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/dashboard-frontend/src/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export class Layout extends React.PureComponent<Props, State> {
}

private logout(): void {
this.keycloakAuthService.logout();
if (KeycloakAuthService.sso) {
this.keycloakAuthService.logout();
} else {
// assume that Che deployed with `nativeUserMode` enabled
window.location.href = '/oauth/sign_out';
}
}

private toggleNav(): void {
Expand Down
9 changes: 7 additions & 2 deletions packages/dashboard-frontend/src/services/keycloak/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,16 @@ export class KeycloakSetupService {

return settings;
} catch (e) {
if (e.response.status === 404) {
if (e.response?.status === 404) {
return;
}

throw new Error(`Can't get Keycloak settings: ${e.response.status} ${e.response.statusText}`);
const errorMessage = 'Cannot get Keycloak settings' + (
e.response?.status === undefined
? '. Response is not available, please check console for details.'
: `: ${e.response?.status} ${e.response?.statusText}`
);
throw new Error(errorMessage);
}
}

Expand Down

0 comments on commit e9bac8a

Please sign in to comment.