- User model (users table) with bcrypt password hashing - JWT-based login API (POST /api/auth/login, GET /api/auth/me) - Default admin account (admin/admin123) auto-created on startup - Login page with centered dark-themed login card - Route guards + Axios interceptors for token management - Login page renders without sidebar (standalone layout) - Gunicorn --preload to avoid worker DDL race condition
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import Dashboard from '../views/Dashboard.vue'
|
|
import Tasks from '../views/Tasks.vue'
|
|
import TaskDetail from '../views/TaskDetail.vue'
|
|
import Agents from '../views/Agents.vue'
|
|
import Alerts from '../views/Alerts.vue'
|
|
import Settings from '../views/Settings.vue'
|
|
import Login from '../views/Login.vue'
|
|
|
|
const routes = [
|
|
{ path: '/login', component: Login, meta: { public: true } },
|
|
{ path: '/', component: Dashboard, meta: { requiresAuth: true } },
|
|
{ path: '/tasks', component: Tasks, meta: { requiresAuth: true } },
|
|
{ path: '/tasks/:id', component: TaskDetail, name: 'TaskDetail', meta: { requiresAuth: true } },
|
|
{ path: '/agents', component: Agents, meta: { requiresAuth: true } },
|
|
{ path: '/alerts', component: Alerts, meta: { requiresAuth: true } },
|
|
{ path: '/settings', component: Settings, meta: { requiresAuth: true } },
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
const token = localStorage.getItem('token')
|
|
if (to.meta.requiresAuth && !token) {
|
|
next('/login')
|
|
} else if (to.path === '/login' && token) {
|
|
next('/')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|