text: import Vue from 'vue'
  import VueRouter from 'vue-router'
  
  import routes from './routes'
  
  Vue.use(VueRouter)
  
  const router = new VueRouter({
    linkActiveClass: 'active',
    routes
  })
  
  router.beforeEach((to, from, next) => {
    if (to.matched.some(record => record.meta.requiresAuth)) {
      // this route requires auth, check if logged in
      // if not, redirect to login page.
      if (!router.app.$auth.hasToken() || !router.app.$auth.isAuthenticated()) {
        next({
          path: '/login',
          query: { redirect: to.fullPath }
        })
      } else {
        next()
      }
    } else {
      next() // make sure to always call next()!
    }
  })
  
  export default router
  