From 60f0dcf11ad8b61818a96e235862621bab0a4457 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Sat, 13 Feb 2021 19:52:46 -0800 Subject: [PATCH] 18.08 Redirect on Log In Log Out --- src/pages/PageAuth.vue | 2 +- src/store/store-auth.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/PageAuth.vue b/src/pages/PageAuth.vue index 57dbfdf..bb3be5a 100644 --- a/src/pages/PageAuth.vue +++ b/src/pages/PageAuth.vue @@ -41,7 +41,7 @@ export default { name: 'Auth', data () { return { - tab: 'register' + tab: 'login' } }, components: { diff --git a/src/store/store-auth.js b/src/store/store-auth.js index 624df4c..8fb7342 100644 --- a/src/store/store-auth.js +++ b/src/store/store-auth.js @@ -33,11 +33,13 @@ const actions = { firebaseAuth.signOut() }, handleAuthStateChange ({ commit }) { - firebaseAuth.onAuthStateChanged(function (user) { + firebaseAuth.onAuthStateChanged(user => { if (user) { commit('setLoggedIn', true) + this.$router.push('/') } else { commit('setLoggedIn', false) + this.$router.replace('/auth') } }) }