Skip to content

User Roles & Permissions

nmpaul17 edited this page May 5, 2025 · 2 revisions

πŸ” User Roles & Permissions

User roles are assigned upon account creation or by an admin through the user management system.
Roles determine access to features such as viewing, editing, adding, or deleting records.
Permissions are enforced on both the frontend (for hiding UI elements) and backend (for API protection).


πŸ‘₯ Defined Roles

🟣 Main Admin

  • Full access to all features and settings
  • Can manage users and assign roles
  • Can perform all Admin and Editor actions

πŸ”΅ Admin

  • Can add, edit, and delete donors, donations, and grants
  • Can view and manage user invitations
  • Cannot assign roles to other users

🟒 Editor

  • Can add and edit records (donors, donations, grants)
  • Cannot delete records or manage users

🟑 Viewer

  • Read-only access to donor and grant data
  • Cannot add, edit, or delete anything
  • Best for auditing or observation

πŸ›‘οΈ Role Enforcement in the Application

  • User object includes role data after login
  • UI elements (e.g., "Add" buttons, "Edit" modals) are conditionally shown based on role
  • API endpoints verify roles before executing sensitive actions
  • Some role checks are still in progress β€” tracked as GitHub issues

πŸ“„ Pages Involved

  • server/api/users/ β€” role assignment and updates
  • middleware/auth.ts β€” route protection
  • Pages with restricted actions:
    • /donors
    • /donations
    • /grants
    • /users

πŸ“ Notes

  • Roles are currently static, defined per user record
  • Consider abstracting role checks into a reusable composable or helper function
  • Future improvement: define roles as enums/constants in a shared roles.config.ts
  • A full role-permission matrix could be implemented for flexibility

Clone this wiki locally