CHS Lite Feature Role Mapping Analysis
This document provides a comprehensive mapping of files/features in the codebase to the roles and permission checks that guard them in the current branch.
Feature Mapping Table
| Filepath | Feature | Rolename |
|---|---|---|
| app/page | Dashboard | None (Public to all authenticated users; sections conditionally shown based on isAdmin, isManager, isSystem, isSecurity, and isMC) |
| app/login/page | Login | None (Public page) |
| app/unauthorized/page | Access Denied | None (Public page) |
| app/profile/page | Profile | None (Public to all authenticated users; conditionally shows Manage Members button for isAdmin || isSA) |
| app/directory/page | Index | None (Public to all authenticated users; shows Manage button if isMC) |
| app/admin/accounts/page | Index | account:view |
| app/admin/accounts/add/page | Create | account:create |
| app/admin/accounts/edit/[id]/page | Edit | account:edit |
| app/admin/accounts/view/[id]/page | View | account:view |
| app/admin/bills/page | Index | bill:view |
| app/admin/bills/view/[id]/page | View | bill:view |
| app/admin/evault/page | Index | vault:view |
| app/admin/evault/add/page | Create | vault:create |
| app/admin/evault/details/[id]/page | Details | vault:view |
| app/admin/evault/edit/[id]/page | Edit | vault:edit |
| app/admin/investments/page | Index | investment:view |
| app/admin/investments/add/page | Create | investment:create |
| app/admin/investments/edit/[id]/page | Edit | investment:edit |
| app/admin/investments/entities/page | Entities | investment:view |
| app/admin/journal-vouchers/page | Index | jv:view |
| app/admin/journal-vouchers/view/[id]/page | View | jv:view |
| app/admin/members/page | Index | member-view |
| app/admin/members/add/page | Create | member-create |
| app/admin/members/details/[id]/page | Details | member-view |
| app/admin/members/edit/[id]/page | Edit | member-edit |
| app/admin/members/import/page | Import | member-create |
| app/admin/opening-balances/page | Index | opening-balance:view |
| app/admin/parking/page | Index | parking:view |
| app/admin/parking/add/page | Create | parking:manage |
| app/admin/parking/edit/[id]/page | Edit | parking:manage |
| app/admin/parking/details/[id]/page | Details | parking:view |
| app/admin/service-charges/page | Index | service-charge:view |
| app/admin/service-charges/add/page | Create | service-charge:create |
| app/admin/service-charges/edit/[id]/page | Edit | service-charge:edit |
| app/admin/service-groups/page | Index | service-group:view |
| app/admin/service-groups/add/page | Create | service-group:create |
| app/admin/service-groups/edit/[id]/page | Edit | service-group:edit |
| app/admin/societies/page | Index | society:view |
| app/admin/societies/add/page | Create | society:create |
| app/admin/societies/edit/[id]/page | Edit | society:edit |
| app/admin/std-instructions/page | Index | Admin | Manager | System (Checks: isAdmin || isManager || isSystem) |
| app/admin/std-instructions/form/page | Form | Admin | Manager | System (Checks: isAdmin || isManager || isSystem) |
| app/admin/system-parameters/page | Index | system:manage |
| app/admin/vendors/page | Index | vendor:view |
| app/admin/vendors/add/page | Create | vendor:create |
| app/admin/vendors/edit/[id]/page | Edit | vendor:edit |
| app/admin/vendors/bank/[id]/page | Bank | vendor-bank:manage |
| app/admin/vouchers/page | Index | voucher:view |
| app/admin/vouchers/view/[id]/page | View | voucher:view |
| app/approvals/page | Index | MC (Checks: isMC -> Admin, Manager, System, Staff) |
| app/invoices/page | Index | invoice:view |
| app/invoices/add/page | Create | invoice:create |
| app/invoices/view/[id]/page | View | invoice:view |
| app/members/page | Index | member-selfview |
| app/notices/page | Index | notice:view |
| app/notices/create/page | Create | notice:create |
| app/notices/edit/[id]/page | Edit | notice:edit |
| app/security/visitors/page | Create | visitor:create (Specifically for Gate/Security role to register walk-ins) |
| app/service-requests/page | Index | service-request:view |
| app/service-requests/add/page | Create | service-request:create |
| app/service-requests/edit/[id]/page | Edit | service-request:edit (Delegates to own-resource check) |
| app/support-requests/page | Index | support:view |
| app/support-requests/add/page | Create | support:manage |
| app/support-requests/edit/[id]/page | Edit | support:manage |
| app/support-requests/[id]/page | Details | support:view (Also close permission checks support:close) |
| app/visitors/page | Index | visitor:view |
| app/visitors/[id]/page | Details | visitor:view |
| app/visitors/book/page | Book | None (Open to all authenticated users) |
| app/visitors/create/page | Create | None (Open to all authenticated users) |
Key Insights & Comparisons with main
-
** Centralized Permissions System (
can)**:- The current branch implements role-to-permission mapping in permissions.ts and exposes the
can()function via theuseAuth()hook in auth-provider.tsx. - This provides much more granular control over actions (e.g. distinguishing
vendor:create,vendor:edit,vendor:delete) compared tomainwhich relied primarily on binary checks likeisAdmin,isMCorcanDelete.
- The current branch implements role-to-permission mapping in permissions.ts and exposes the
-
Unmigrated / Legacy Checks:
- Several pages/features in the current branch still use the legacy role checks (
isAdmin,isMC,isSystem) instead of the centralizedcan(...)permission checks. These are:- Standard Instructions: std-instructions/page.tsx and std-instructions/form/page.tsx (uses
isAdmin \|\| isManager \|\| isSystem). - Approvals: approvals/page.tsx (uses
isMC). - Directory: directory/page.tsx (uses
isMCfor conditional Manage button). - Profile: profile/page.tsx (uses
isSA,isManager,isAdmin,isSecurityfor conditional view rendering).
- Standard Instructions: std-instructions/page.tsx and std-instructions/form/page.tsx (uses
- Several pages/features in the current branch still use the legacy role checks (