|
|
@@ -1,6 +1,8 @@
|
|
|
import Vue from 'vue'
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
|
|
+import { isUserLoggedIn } from '../auth/utils'
|
|
|
+
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
@@ -76,10 +78,7 @@ const router = new VueRouter({
|
|
|
})
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- if (to.path === '/login' || to.path === '/error-404' || localStorage.getItem('accessToken') != null) {
|
|
|
- if (to.path === '/login') {
|
|
|
- localStorage.clear()
|
|
|
- }
|
|
|
+ if (to.path === '/login' || to.path === '/error-404' || isUserLoggedIn()) {
|
|
|
next()
|
|
|
} else {
|
|
|
next({ path: '/login', query: { redirect: to.fullPath } })
|