SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. firebase.initializeApp(firebaseConfig);
  2. firebase.auth().onAuthStateChanged(function(user){...}
  3.      
  4. router.beforeEach((to, from, next) => {
  5.   console.log("router | beforeEach")
  6.   const currentUser = firebase.auth().currentUser;
  7.   const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
  8.  
  9.   if(requiresAuth && (!currentUser || currentUser.isAnonymous)) next('login')
  10.   else if(!requiresAuth && currentUser) next('eorDashboard')
  11.   else next();
  12. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top