diff --git a/dashboard/login.html b/dashboard/login.html index 2f34603b4..6113ec5f4 100644 --- a/dashboard/login.html +++ b/dashboard/login.html @@ -4,7 +4,7 @@ - ##NAME## + ##NAME## Login @@ -17,7 +17,6 @@ } - +
diff --git a/dashboard/src/Index.vue b/dashboard/src/Index.vue index 7962649ae..1c89f6963 100644 --- a/dashboard/src/Index.vue +++ b/dashboard/src/Index.vue @@ -66,8 +66,8 @@ fetcher.globalOptions.errorHook = (error) => { return offlineOverlay.value.open(); } - // // re-login will make the code get a new token - // if (status === 401) return client.login(); + // re-login will make the code get a new token + if (error.status === 401) return profileModel.logout(); if (error.status === 500 || error.status === 501) { // actual internal server error, most likely a bug or timeout log to console only to not alert the user @@ -140,7 +140,7 @@ function onHashChange() { view.value = VIEWS.EVENTLOG; } else if (v === VIEWS.NETWORK && profile.value.isAtLeastAdmin) { view.value = VIEWS.NETWORK; - } else if (v === VIEWS.PROFILE) { + } else if (v.indexOf(VIEWS.PROFILE) === 0) { view.value = VIEWS.PROFILE; } else if (v === VIEWS.SERVICES && profile.value.isAtLeastAdmin) { view.value = VIEWS.SERVICES; @@ -175,9 +175,6 @@ onMounted(async () => { if (error) return console.error(error); profile.value = result; - window.addEventListener('hashchange', onHashChange); - onHashChange(); - [error, result] = await dashboardModel.config(); if (error) return console.error(error); config.value = result; @@ -191,6 +188,11 @@ onMounted(async () => { window.document.body.classList.add('has-background'); } + if (config.value.mandatory2FA && !profile.value.twoFactorAuthenticationEnabled) window.location.hash = `/${VIEWS.PROFILE}?setup2fa`; + + window.addEventListener('hashchange', onHashChange); + onHashChange(); + ready.value = true; }); diff --git a/dashboard/src/components/Login.vue b/dashboard/src/components/Login.vue index d71fabdc2..fdadd348e 100644 --- a/dashboard/src/components/Login.vue +++ b/dashboard/src/components/Login.vue @@ -92,10 +92,11 @@ export default {