Fix redirect when not logged in

This commit is contained in:
kolaente 2020-05-16 12:02:30 +02:00
parent f63576960d
commit c4b92a8f52
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 19 additions and 16 deletions

View file

@ -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})

View file

@ -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) {