From e2dec4f1c6ac704043f64f6cb7c527af94181915 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Mon, 15 Feb 2021 05:55:58 -0800 Subject: [PATCH] 20.02 Read Data when user Logs In --- src/store/store-auth.js | 3 ++- src/store/store-tasks.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store/store-auth.js b/src/store/store-auth.js index 8d39215..a2dd773 100644 --- a/src/store/store-auth.js +++ b/src/store/store-auth.js @@ -37,13 +37,14 @@ const actions = { logoutUser () { firebaseAuth.signOut() }, - handleAuthStateChange ({ commit }) { + handleAuthStateChange ({ commit, dispatch }) { firebaseAuth.onAuthStateChanged(user => { Loading.hide() if (user) { commit('setLoggedIn', true) /* eslint handle-callback-err: "off" */ this.$router.push('/').catch(err => {}) + dispatch('tasks/fbReadData', null, { root: true }) } else { commit('setLoggedIn', false) this.$router.replace('/auth').catch(err => { }) diff --git a/src/store/store-tasks.js b/src/store/store-tasks.js index 24fb1c2..350e321 100644 --- a/src/store/store-tasks.js +++ b/src/store/store-tasks.js @@ -66,6 +66,9 @@ const actions = { }, setSort ({ commit }, value) { commit('setSort', value) + }, + fbReadData ({ commit }) { + console.log('read data from database') } }