This is an automated email from the ASF dual-hosted git repository. DaanHoogland pushed a commit to branch ghi14528-login-undefined-sessionkey in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit cf64acb4631efbb991065091fb6f8bcfa45746f0 Author: Daan Hoogland <[email protected]> AuthorDate: Thu Nov 5 14:46:02 2026 +0100 ui: login session checked before proceding. --- ui/src/main.js | 18 +++++++++++++++++- ui/src/store/modules/user.js | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ui/src/main.js b/ui/src/main.js index 7441f801086..0abc3d0852a 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -68,8 +68,23 @@ vueApp.use(backupUtilPlugin) vueApp.use(extensions) vueApp.use(directives) +// drop stored values that are not valid JSON (e.g. 'undefined'), as reading them throws +vueProps.$localStorage.keys().forEach(key => { + try { + vueProps.$localStorage.get(key) + } catch (e) { + console.warn('Removing unreadable local storage entry: ' + key) + vueProps.$localStorage.remove(key) + } +}) + +let configLoaded = false + const renderError = (err) => { console.error('Fatal error during app initialization: ', err) + const details = configLoaded + ? 'The application failed to start: ' + err + '. Check the browser console for more information.' + : 'Missing or malformed config.json. Please ensure the file is present, accessible, and contains valid JSON. Check the browser console for more information.' const ErrorComponent = { render: () => h( 'div', @@ -81,7 +96,7 @@ const renderError = (err) => { h('summary', { style: 'cursor: pointer;' }, 'Technical details'), h('pre', { style: 'text-align: left; display: inline-block; margin-top: 10px;' - }, 'Missing or malformed config.json. Please ensure the file is present, accessible, and contains valid JSON. Check the browser console for more information.') + }, details) ]) ] ) @@ -97,6 +112,7 @@ fetch('config.json?ts=' + Date.now()) return response.json() }) .then(async config => { + configLoaded = true vueProps.$config = config let baseUrl = config.apiBase if (config.multipleServer) { diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js index 4103ff920d6..87a48dd9396 100644 --- a/ui/src/store/modules/user.js +++ b/ui/src/store/modules/user.js @@ -64,7 +64,10 @@ function setLoginCookies (result) { } function processLoginResponse (commit, response) { - const result = response.loginresponse || {} + const result = response?.loginresponse || {} + if (!result.sessionkey) { + throw new Error('Login response not valid.') + } setLoginCookies(result) vueProps.$localStorage.set(ACCESS_TOKEN, result.sessionkey, 24 * 60 * 60 * 1000) commit('SET_TOKEN', result.sessionkey)
