4.2.3.2 Configure user roles
👥 Configuring User Roles
src/data-seeding/roles/roles.ts🧩 Role structure in roles.ts
roles.tsimport { SCOPES, Scope } from '@opencrvs/toolkit/scopes'
import { MessageDescriptor } from 'react-intl'
type Role = {
id: string
label: MessageDescriptor
scopes: Scope[]
}
export const roles: Role[] = [
{
id: 'FIELD_AGENT',
label: {
id: 'userRole.fieldAgent',
defaultMessage: 'Field Agent',
description: 'Name for user role Field Agent'
},
scopes: [
SCOPES.RECORD_DECLARE_BIRTH,
SCOPES.RECORD_DECLARE_DEATH,
SCOPES.RECORD_DECLARE_MARRIAGE,
SCOPES.RECORD_SUBMIT_INCOMPLETE,
SCOPES.RECORD_SUBMIT_FOR_REVIEW,
SCOPES.SEARCH_BIRTH,
SCOPES.SEARCH_DEATH,
SCOPES.SEARCH_MARRIAGE,
'search[event=birth,access=all]',
'search[event=death,access=my-jurisdiction]',
'search[event=tennis-club-membership,access=all]',
'workqueue[id=assigned-to-you|recent|requires-updates-self|sent-for-review]',
`record.create[event=birth|death|tennis-club-membership]`,
'record.declare[event=birth|death|tennis-club-membership]',
'record.notify[event=birth|death|tennis-club-membership]'
]
},
// ... other roles (POLICE_OFFICER, HOSPITAL_CLERK, COMMUNITY_LEADER, etc.)
]🔑 id: Internal role identifier
id: Internal role identifier🏷 label: What users see in the UI
label: What users see in the UI🎯 scopes: What the role is allowed to do
scopes: What the role is allowed to do⚠️ Deprecated scopes (still present in examples)
📘 Source of truth
Last updated