From aecb1d3c80cddebd2a7f18e85b4562d55e39bb0c Mon Sep 17 00:00:00 2001 From: Filip Borum Poulsen Date: Fri, 28 Apr 2023 08:58:53 +0200 Subject: [PATCH] Changed home login redirect logic to fetch user --- client/src/views/Home.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue index 586d647..14f9fed 100644 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -120,10 +120,14 @@ export default { TrainerSelector, OrderPopup }, - created() { + async created() { // this.parseQueryFilters(); - if (!this.loggedIn) { - this.$router.push({path: "/login"}) + const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/user`, { + credentials: import.meta.env.DEV ? "include" : undefined + }); + if (res.status === 401 || res.status === 403) { + this.setLoginState(false); + this.$router.push({ path: "/login" }) } }, data() {