Fix redirect when not logged in
This commit is contained in:
parent
f63576960d
commit
c4b92a8f52
2 changed files with 19 additions and 16 deletions
34
src/App.vue
34
src/App.vue
|
@ -264,25 +264,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeCreate() {
|
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('config/update')
|
||||||
this.$store.dispatch('auth/checkAuth')
|
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)) {
|
if (this.userAuthenticated && this.userInfo.type === authTypes.USER && (this.$route.params.name === 'home' || this.namespaces.length === 0)) {
|
||||||
this.loadNamespaces()
|
this.loadNamespaces()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
|
||||||
// Service worker communication
|
// Service worker communication
|
||||||
document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true})
|
document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true})
|
||||||
|
|
|
@ -119,6 +119,7 @@ export default {
|
||||||
ctx.commit('info', info)
|
ctx.commit('info', info)
|
||||||
}
|
}
|
||||||
ctx.commit('authenticated', authenticated)
|
ctx.commit('authenticated', authenticated)
|
||||||
|
return Promise.resolve()
|
||||||
},
|
},
|
||||||
// Renews the api token and saves it to local storage
|
// Renews the api token and saves it to local storage
|
||||||
renewToken(ctx) {
|
renewToken(ctx) {
|
||||||
|
|
Loading…
Reference in a new issue