1const router = new VueRouter({
2 ...
3});
4router.beforeEach((to, from, next) => {
5 const currentUser = firebase.auth().currentUser;
6 const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
7 if (requiresAuth && !currentUser) next('login');
8 else if (!requiresAuth && currentUser) next('dashboard');
9 else next();
10});
11new Vue({
12 ...