Created
March 7, 2019 21:23
-
-
Save brunokunace/81a44f284ec511f8ed9201e83607829b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import firebase from '@store/firebase' | |
import store from '@store' | |
import { USER } from '@store/types' | |
export default async (to, from, next) => { | |
if (to.name === 'Sign in') { | |
next() | |
return | |
} | |
await firebase.auth().onAuthStateChanged(user => { | |
if (user) { | |
store.dispatch(USER, user) | |
next() | |
} | |
else next({ name: 'Sign in' }) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment