Skip to content

Commit

Permalink
Login fix (#222)
Browse files Browse the repository at this point in the history
 fixed problem with node visibility w/o auth enabled
  • Loading branch information
hardl authored and kwiatekus committed Nov 20, 2018
1 parent 2d10512 commit c6acf88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
7 changes: 3 additions & 4 deletions core/src/Authorization.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@

export default {
oncreate() {
const idpProviderName = LuigiConfig.getConfigValue('auth.use');
const idpProviderSettings = LuigiConfig.getConfigValue(`auth.${idpProviderName}`);
const authorizationEnabled = !!idpProviderSettings;
if (!authorizationEnabled) {
if (!LuigiConfig.isAuthorizationEnabled()) {
return;
}

Expand All @@ -82,6 +79,8 @@
}
};

const idpProviderName = LuigiConfig.getConfigValue('auth.use');
const idpProviderSettings = LuigiConfig.getConfigValue(`auth.${idpProviderName}`);
idpProviderInstance = getIdpProviderInstance(idpProviderName, idpProviderSettings);
if (isPromise(idpProviderInstance)) {
return idpProviderInstance.then((resolved) => {
Expand Down
6 changes: 1 addition & 5 deletions core/src/navigation/TopNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,8 @@

export default {
oncreate() {
// Authentication detection
const idpProviderName = LuigiConfig.getConfigValue('auth.use');
const idpProviderSettings = LuigiConfig.getConfigValue(`auth.${idpProviderName}`);

this.set({
authorizationEnabled: !!idpProviderSettings,
authorizationEnabled: LuigiConfig.isAuthorizationEnabled(),
hideNavComponent: LuigiConfig.getConfigBooleanValue('settings.hideNavigation')
});
},
Expand Down
2 changes: 1 addition & 1 deletion core/src/navigation/services/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isNodeAccessPermitted = (
parentNode,
currentContext
) => {
if (!isLoggedIn()) return false;
if (LuigiConfig.isAuthorizationEnabled() && !isLoggedIn()) return false;
const permissionCheckerFn = LuigiConfig.getConfigValue(
'navigation.nodeAccessibilityResolver'
);
Expand Down
10 changes: 10 additions & 0 deletions core/src/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ class LuigiConfigManager {
parameters
);
}

/*
* Detects if authorization is enabled via configuration.
* @returns {boolean} returns true if authorization is enabled. Otherwise returns false.
*/
isAuthorizationEnabled() {
const idpProviderName = this.getConfigValue('auth.use');
const idpProviderSettings = this.getConfigValue(`auth.${idpProviderName}`);
return !!idpProviderSettings;
}
}
const LuigiInstance = new LuigiConfigManager();

Expand Down

0 comments on commit c6acf88

Please sign in to comment.