From eec02a55a4d54d41400d4b6fbad92661bbdd7ec7 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sat, 2 Oct 2021 23:28:37 +0200 Subject: [PATCH] fix: wait with redirect until route name is available --- src/components/home/contentNoAuth.vue | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/home/contentNoAuth.vue b/src/components/home/contentNoAuth.vue index a4e5fa0e..8229c799 100644 --- a/src/components/home/contentNoAuth.vue +++ b/src/components/home/contentNoAuth.vue @@ -27,12 +27,23 @@ export default { logoUrl, } }, - created() { - this.redirectToHome() + computed: { + routeName() { + return this.$route.name + }, + ...mapState({ + motd: state => state.config.motd, + }), + }, + watch: { + routeName: { + handler(routeName) { + if (!routeName) return + this.redirectToHome() + }, + immediate: true, + }, }, - 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