Created
September 19, 2018 03:29
-
-
Save h-sakano/d9ac7c6ae0dea8f57d956ca7a73e4005 to your computer and use it in GitHub Desktop.
Firebase Authentication Plugin
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 "~/plugins/firebase" | |
export default ({ app, redirect, store }) => { | |
app.router.afterEach((to, from) => { | |
firebase.auth().onAuthStateChanged((user) => { | |
store.commit("user/setUser", user) | |
if (user) { | |
if (to.name === "signin") { | |
redirect("/") | |
} | |
} | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment