{"size": 1227, "ext": "js", "max_stars_repo_path": "client/src/router.js", "max_stars_repo_name": "dejo095/vault", "max_stars_repo_stars_event_min_datetime": "2020-08-08T16:56:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-08T16:56:51.000Z", "max_issues_repo_path": "client/src/router.js", "max_issues_repo_name": "dejo095/vault", "max_issues_repo_issues_event_min_datetime": "2020-07-16T21:18:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T10:14:50.000Z", "max_forks_repo_path": "client/src/router.js", "max_forks_repo_name": "dejo095/vault", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 20.7966101695, "max_line_length": 55, "alphanum_fraction": 0.5012224939}
import Vue from 'vue';
import Router from 'vue-router';
import Home from './views/Home.vue';
import store from './store/store';

Vue.use(Router);

function isLoggedIn(to, from, next) {
  store.dispatch('auth/authenticate').then(() => {
    next();
  }).catch(() => {
    next('/login');
  });
}


export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      beforeEnter(to, from, next) {
        store.dispatch('auth/authenticate')
          .then(() => {
            next('/dashboard');
          })
          .catch(() => {
            next('/login');
          });
      },
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('./views/Login.vue'),
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('./views/Register.vue'),
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('./views/Dashboard.vue'),
      beforeEnter: isLoggedIn,
    },
    {
      path: '/dashboard/settings',
      name: 'settings',
      component: () => import('@/views/Settings.vue'),
      beforeEnter: isLoggedIn,
    },
  ],
});
