feature: RBAC + Clinical Audit Logging
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/ward',
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('@/views/LoginView.vue'),
|
||||
meta: { title: 'Sign In', public: true },
|
||||
},
|
||||
{
|
||||
path: '/ward',
|
||||
name: 'WardDashboard',
|
||||
@@ -38,6 +45,14 @@ const router = createRouter({
|
||||
|
||||
router.beforeEach((to) => {
|
||||
document.title = `${to.meta.title ?? 'VigilCare'} — VigilCare`
|
||||
|
||||
const auth = useAuthStore()
|
||||
if (!to.meta.public && !auth.isAuthenticated) {
|
||||
return { path: '/login', query: { redirect: to.fullPath } }
|
||||
}
|
||||
if (to.path === '/login' && auth.isAuthenticated) {
|
||||
return { path: '/ward' }
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user