Fix redirect when not logged in
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2020-05-16 12:02:30 +02:00
parent f63576960d
commit c4b92a8f52
Signed by: konrad
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) {