Answers for "routing vue with meta tag firebase"

0

routing vue with meta tag firebase

const router = new VueRouter({
  ...
});
router.beforeEach((to, from, next) => {
  const currentUser = firebase.auth().currentUser;
  const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
  if (requiresAuth && !currentUser) next('login');
  else if (!requiresAuth && currentUser) next('dashboard');
  else next();
});
new Vue({
  ...
Posted by: Guest on June-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language