routing vue with meta tag firebase

Solutions on MaxInterview for routing vue with meta tag firebase by the best coders in the world

showing results for - "routing vue with meta tag firebase"
Alexandra
29 Jan 2019
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  ...