Debug sessions

This commit is contained in:
Kevin Thomas
2021-07-26 16:17:51 -07:00
parent 1be716d85a
commit 9571cd0224
7 changed files with 16089 additions and 52 deletions

View File

@@ -1,7 +1,13 @@
import Vue from 'vue'
import Axios from 'axios'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
const instance = Axios.create({
baseURL: 'https://localhost:3000',
withCredentials: true
})
Vue.use(VueRouter)
const routes = [
@@ -34,4 +40,23 @@ const router = new VueRouter({
routes
})
router.beforeEach((to, from, next) => {
if (to.name === 'Home') {
instance.get('/auth')
.then(response => {
if (response.status === 200) {
next()
} else {
next('/login')
}
})
.catch(function (error) {
console.error(error.response)
next('/login')
})
} else {
next()
}
})
export default router