routing vue with meta tag firebase code example
Example: 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({
...