diff --git a/src/App.vue b/src/App.vue index 0ca0f35e..ae177aa1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -264,25 +264,27 @@ } }, beforeCreate() { - // Check if the user is already logged in, if so, redirect them to the homepage - if ( - !this.userAuthenticated && - this.$route.name !== 'login' && - this.$route.name !== 'getPasswordReset' && - this.$route.name !== 'passwordReset' && - this.$route.name !== 'register' && - this.$route.name !== 'linkShareAuth' - ) { - router.push({name: 'login'}) - } - }, - created() { this.$store.dispatch('config/update') this.$store.dispatch('auth/checkAuth') + .then(() => { + // Check if the user is already logged in, if so, redirect them to the homepage + if ( + !this.userAuthenticated && + this.$route.name !== 'login' && + this.$route.name !== 'getPasswordReset' && + this.$route.name !== 'passwordReset' && + this.$route.name !== 'register' && + this.$route.name !== 'linkShareAuth' + ) { + router.push({name: 'login'}) + } - if (this.userAuthenticated && this.userInfo.type === authTypes.USER && (this.$route.params.name === 'home' || this.namespaces.length === 0)) { - this.loadNamespaces() - } + if (this.userAuthenticated && this.userInfo.type === authTypes.USER && (this.$route.params.name === 'home' || this.namespaces.length === 0)) { + this.loadNamespaces() + } + }) + }, + created() { // Service worker communication document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true}) diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index 75dbe531..d991c153 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -119,6 +119,7 @@ export default { ctx.commit('info', info) } ctx.commit('authenticated', authenticated) + return Promise.resolve() }, // Renews the api token and saves it to local storage renewToken(ctx) {