diff --git a/core/src/Authorization.html b/core/src/Authorization.html index b4fd0d1cda..c9c78489ce 100644 --- a/core/src/Authorization.html +++ b/core/src/Authorization.html @@ -232,9 +232,9 @@ checkAuth(idpProviderSettings); }) .catch(err => { - console.error( - `Could not instantate ${idpProviderName} provider : ${err}` - ); + const errorMsg = `Error: ${err.message || err}`; + console.error(errorMsg, err.message && err); + LuigiConfig.setErrorMessage(errorMsg); }); } checkAuth(idpProviderSettings); diff --git a/core/src/core-api/auth.js b/core/src/core-api/auth.js index 9eab4c9b79..cc235c5a69 100644 --- a/core/src/core-api/auth.js +++ b/core/src/core-api/auth.js @@ -10,11 +10,7 @@ class LuigiAuthManager { * @returns {boolean} returns true if authorization is enabled. Otherwise returns false. */ isAuthorizationEnabled() { - const idpProviderName = config.getConfigValue('auth.use'); - const idpProviderSettings = config.getConfigValue( - `auth.${idpProviderName}` - ); - return !!idpProviderSettings; + return !!config.getConfigValue('auth.use'); } async handleAuthEvent( diff --git a/core/src/core-api/config.js b/core/src/core-api/config.js index a39343dd24..5cd930cc6d 100644 --- a/core/src/core-api/config.js +++ b/core/src/core-api/config.js @@ -9,14 +9,14 @@ class LuigiConfigManager { id: undefined }; - this.configReadyCallback = function() {}; + this.configReadyCallback = function () { }; } setConfigCallbacks(configReadyCallback) { this.configReadyCallback = configReadyCallback; this.configReadyTimeout.id = setTimeout(() => { // Avoid Luigi initialization if timeout reached - this.configReadyCallback = function() {}; + this.configReadyCallback = function () { }; this.configNotReadyCallback(); }, this.configReadyTimeout.valueMs); } @@ -35,6 +35,10 @@ class LuigiConfigManager { const errorMsg = 'Ups.. Looks like Luigi was not configured. Please use Luigi.setConfig(config) function to configure Luigi.'; console.error(errorMsg); + this.setErrorMessage(errorMsg); + } + + setErrorMessage(errorMsg) { var errorTextNode = document.createTextNode(errorMsg); var fd_ui = document.createElement('div'); fd_ui.setAttribute('class', 'fd-ui'); diff --git a/core/src/core-api/index.js b/core/src/core-api/index.js index 8662fd3594..5af39d93ec 100644 --- a/core/src/core-api/index.js +++ b/core/src/core-api/index.js @@ -5,7 +5,4 @@ export const LuigiConfig = config; export const LuigiAuth = auth; // Expose it window for user app to call Luigi.setConfig() -window.Luigi = Object.assign( - config, - auth -); +window.Luigi = Object.assign(config, auth); diff --git a/core/src/navigation/TopNav.html b/core/src/navigation/TopNav.html index a8ef941fac..b9714d5b3d 100644 --- a/core/src/navigation/TopNav.html +++ b/core/src/navigation/TopNav.html @@ -1,4 +1,4 @@ - + {#if showTopNav}
diff --git a/core/src/utilities/helpers/generic-helpers.js b/core/src/utilities/helpers/generic-helpers.js index abc67d9768..a1732a60a8 100644 --- a/core/src/utilities/helpers/generic-helpers.js +++ b/core/src/utilities/helpers/generic-helpers.js @@ -77,14 +77,13 @@ export const getPathWithoutHash = path => { * Returns the value of a given url parameter name * @param {string} name */ -export const getUrlParameter = (name) => { +export const getUrlParameter = name => { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var result = regex.exec(window.location.search); - return result && decodeURIComponent(result[1].replace(/\+/g, ' ')) || ''; + return (result && decodeURIComponent(result[1].replace(/\+/g, ' '))) || ''; }; - /** * Prepend current url to redirect_uri, if it is a relative path * @param {path} string full url, relative or absolute path @@ -185,9 +184,9 @@ export const replaceVars = ( new RegExp( escapeRegExp( (parenthesis ? '{' : '') + - prefix + - entry[0] + - (parenthesis ? '}' : '') + prefix + + entry[0] + + (parenthesis ? '}' : '') ), 'g' ), diff --git a/core/test/utilities/helpers/async-helpers.spec.js b/core/test/utilities/helpers/async-helpers.spec.js index b63caef6ce..b1e0c64f06 100644 --- a/core/test/utilities/helpers/async-helpers.spec.js +++ b/core/test/utilities/helpers/async-helpers.spec.js @@ -27,9 +27,13 @@ describe('Async-helpers', () => { it('executes a pure function and returns a new promise', async () => { const plainFunc = (one, two, three) => { return three; - } + }; const thirdParam = 'hello'; - const prom = AsyncHelpers.applyFunctionPromisified(plainFunc, [undefined, undefined, thirdParam]); + const prom = AsyncHelpers.applyFunctionPromisified(plainFunc, [ + undefined, + undefined, + thirdParam + ]); assert.isTrue(GenericHelpers.isPromise(prom), 'is a promise'); assert.equal(await prom, thirdParam, 'value is equal'); @@ -37,10 +41,16 @@ describe('Async-helpers', () => { it('executes an async function and returns its promise', async () => { const promiseFunc = (one, two, three) => { - return new Promise((resolve) => { resolve(three); }); - } + return new Promise(resolve => { + resolve(three); + }); + }; const thirdParam = 'hello'; - const prom = AsyncHelpers.applyFunctionPromisified(promiseFunc, [undefined, undefined, thirdParam]); + const prom = AsyncHelpers.applyFunctionPromisified(promiseFunc, [ + undefined, + undefined, + thirdParam + ]); assert.isTrue(GenericHelpers.isPromise(prom), 'is a promise'); assert.equal(await prom, thirdParam, 'value is equal');