Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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({
  ...
Source by weichie.com #
 
PREVIOUS NEXT
Tagged: #routing #vue #meta #tag #firebase
ADD COMMENT
Topic
Name
3+9 =