0👍
I have put the logic in a vuex-mutation:
retrieveUser(state) {
auth.onAuthStateChanged((user) => {
if (user === null) {
state.user.key = null
} else {
state.user.key = user.uid
router.replace('/forum')
}
})
},
and I call it in the beforeCreate
of my component:
this.$store.dispatch('RETRIEVE_USER')
Source:stackexchange.com