Skip to content

Instantly share code, notes, and snippets.

@h-sakano
Created September 19, 2018 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-sakano/d9ac7c6ae0dea8f57d956ca7a73e4005 to your computer and use it in GitHub Desktop.
Save h-sakano/d9ac7c6ae0dea8f57d956ca7a73e4005 to your computer and use it in GitHub Desktop.
Firebase Authentication Plugin
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