From ed18dce3eaf569eb302abe54d1b7431190e648c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 7 May 2019 22:28:51 +0200 Subject: [PATCH] login/logout routing --- frontend/src/components/forms/Login.vue | 1 + frontend/src/views/About.vue | 14 +++++++++++--- frontend/src/views/Home.vue | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/forms/Login.vue b/frontend/src/components/forms/Login.vue index b046de5..f589f6d 100644 --- a/frontend/src/components/forms/Login.vue +++ b/frontend/src/components/forms/Login.vue @@ -56,6 +56,7 @@ export default { if (response.data.success) { Cookies.set('session', response.data.message, { expires: 30 }) console.log('cookie', Cookies.get()) + this.$router.push('about') } }) } diff --git a/frontend/src/views/About.vue b/frontend/src/views/About.vue index 9b52346..79a630c 100644 --- a/frontend/src/views/About.vue +++ b/frontend/src/views/About.vue @@ -23,6 +23,11 @@ export default { }), methods: { + goHome() { + Cookies.remove('session') + this.$router.push({ name: 'home' }) + }, + logout() { axios .post('/user/logout', { @@ -30,8 +35,7 @@ export default { }) .then(response => { if (response.data.success) { - Cookies.remove('session') - this.$router.push({name: 'home'}) + this.goHome() } }) } @@ -43,7 +47,11 @@ export default { session: Cookies.get('session') }) .then(response => { - this.sessionID = response.data.message + if (response.data.success) { + this.sessionID = response.data.message + } else { + this.goHome() + } }) } } diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index fabeab2..e6bbb15 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -15,19 +15,38 @@