Move redirect to home to no auth component

This commit is contained in:
kolaente 2020-11-01 17:55:57 +01:00
parent 00d1f9b784
commit e87243e3f1
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 17 additions and 0 deletions

View File

@ -18,8 +18,25 @@ import {mapState} from 'vuex'
export default {
name: 'contentNoAuth',
beforeCreate() {
this.redirectToHome()
},
computed: mapState({
motd: state => state.config.motd,
}),
methods: {
redirectToHome() {
// Check if the user is already logged in and redirect them to the home page if not
if (
this.$route.name !== 'user.login' &&
this.$route.name !== 'user.password-reset.request' &&
this.$route.name !== 'user.password-reset.reset' &&
this.$route.name !== 'user.register' &&
this.$route.name !== 'link-share.auth'
) {
this.$router.push({name: 'user.login'})
}
},
},
}
</script>