feat/menu-structure: update access control
This commit is contained in:
+48
-48
@@ -2,67 +2,67 @@ import type { RoleAccess } from '~/models/role'
|
||||
|
||||
export const PAGE_PERMISSIONS = {
|
||||
'/patient': {
|
||||
doctor: ['R'],
|
||||
nurse: ['R'],
|
||||
admisi: ['C', 'R', 'U', 'D'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['R'],
|
||||
'emp|nur': ['R'],
|
||||
'emp|reg': ['C', 'R', 'U', 'D'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/doctor': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['R'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['R'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/satusehat': {
|
||||
doctor: ['R'],
|
||||
nurse: ['R'],
|
||||
admisi: ['C', 'R', 'U', 'D'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['R'],
|
||||
'emp|nur': ['R'],
|
||||
'emp|reg': ['C', 'R', 'U', 'D'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/outpatient/encounter': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['C', 'R', 'U', 'D'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['C', 'R', 'U', 'D'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/emergency/encounter': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['C', 'R', 'U', 'D'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['C', 'R', 'U', 'D'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/inpatient/encounter': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['C', 'R', 'U', 'D'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['C', 'R', 'U', 'D'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/rehab/encounter': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['R'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['R'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
'/rehab/registration': {
|
||||
doctor: ['C', 'R', 'U', 'D'],
|
||||
nurse: ['R'],
|
||||
admisi: ['R'],
|
||||
pharmacy: ['R'],
|
||||
billing: ['R'],
|
||||
management: ['R'],
|
||||
'emp|doc': ['C', 'R', 'U', 'D'],
|
||||
'emp|nur': ['R'],
|
||||
'emp|reg': ['R'],
|
||||
'emp|pha': ['R'],
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
} as const satisfies Record<string, RoleAccess>
|
||||
|
||||
+24
-5
@@ -5,12 +5,13 @@ export const useUserStore = defineStore(
|
||||
// const token = useCookie('authentication')
|
||||
|
||||
const isAuthenticated = computed(() => !!user.value)
|
||||
|
||||
const userRole = computed(() => {
|
||||
const roles = user.value?.roles || []
|
||||
return roles.map((input: string) => {
|
||||
const parts = input.split('-')
|
||||
return parts.length > 1 ? parts[1]: parts[0]
|
||||
})
|
||||
return user.value?.roles || []
|
||||
// return roles.map((input: string) => {
|
||||
// const parts = input.split('|')
|
||||
// return parts.length > 1 ? parts[1]: parts[0]
|
||||
// })
|
||||
})
|
||||
|
||||
const login = async (userData: any) => {
|
||||
@@ -21,12 +22,30 @@ export const useUserStore = defineStore(
|
||||
user.value = null
|
||||
}
|
||||
|
||||
const setActiveRole = (role: string) => {
|
||||
if (user.value && user.value.roles.includes(role)) {
|
||||
user.value.activeRole = role
|
||||
}
|
||||
}
|
||||
|
||||
const getActiveRole = () => {
|
||||
if (user.value?.activeRole) {
|
||||
return user.value.activeRole
|
||||
}
|
||||
if (user.value?.roles.length > 0) {
|
||||
user.value.activeRole = user.value.roles[0]
|
||||
return user.value.activeRole
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
user,
|
||||
isAuthenticated,
|
||||
userRole,
|
||||
login,
|
||||
logout,
|
||||
setActiveRole,
|
||||
getActiveRole,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user