|
|
@@ -127,6 +127,14 @@ const router = createRouter({
|
|
|
})
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
+ const token = localStorage.getItem('token')
|
|
|
+
|
|
|
+ // If user is already logged in and tries to access login page, redirect to dashboard
|
|
|
+ if (token && to.path === '/login') {
|
|
|
+ next('/dashboard')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// Public routes
|
|
|
const publicRoutes = ['/login', '/register', '/consent', '/reset-password', '/setup']
|
|
|
if (publicRoutes.includes(to.path)) {
|
|
|
@@ -134,7 +142,6 @@ router.beforeEach((to, from, next) => {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- const token = localStorage.getItem('token')
|
|
|
if (to.meta.requiresAuth && !token) {
|
|
|
next('/login')
|
|
|
} else {
|