Commit graph

7 commits

Author SHA1 Message Date
Dustin Healy
7d776de71a fix: address external review findings for admin roles
- Block renaming system roles (ADMIN/USER) and add user migration on rename
- Add input validation: name max-length, trim on update, duplicate name check
- Replace fragile String.includes error matching with prefix-based classification
- Catch MongoDB 11000 duplicate key in createRoleByName
- Add pagination (limit/offset/total) to getRoleMembersHandler
- Reverse delete order in deleteRoleByName — reassign users before deletion
- Add role existence check in removeRoleMember; drop unused createdAt select
- Add Array.isArray guard for permissions input; use consistent ?? coalescing
- Fix import ordering per AGENTS.md conventions
- Type-cast mongoose.models.User as Model<IUser> for proper TS inference
- Add comprehensive tests: rename guards, pagination, validation, 500 paths
2026-03-26 15:30:33 -07:00
Dustin Healy
88abca5d6d fix: allow system role updates when name is unchanged
The updateRoleHandler guard rejected any request where body.name matched
a system role, even when the name was not being changed. This blocked
editing a system role's description. Compare against the URL param to
only reject actual renames to reserved names.
2026-03-26 14:50:57 -07:00
Dustin Healy
f57d90c0d7 fix: address Copilot review findings in admin roles handlers 2026-03-26 14:50:27 -07:00
Dustin Healy
afda763bcd feat: add description field to Role model
- Add description to IRole, CreateRoleRequest, UpdateRoleRequest types
- Add description field to Mongoose roleSchema (default: '')
- Wire description through createRoleHandler and updateRoleHandler
- Include description in listRoles select clause so it appears in list
2026-03-26 14:50:27 -07:00
Dustin Healy
f947546fea fix: rename createRole/deleteRole to avoid AccessRole name collision
The existing accessRole.ts already exports createRole/deleteRole for the
AccessRole model. In createMethods index.ts, these are spread after
roleMethods, overwriting them. Renamed our Role methods to
createRoleByName/deleteRoleByName to match the existing pattern
(getRoleByName, updateRoleByName) and avoid the collision.
2026-03-26 14:50:27 -07:00
Dustin Healy
69093a5d99 fix: address convention violations in admin roles handlers 2026-03-26 14:50:27 -07:00
Dustin Healy
452333ee4d feat: add admin roles handler factory and Express routes 2026-03-26 14:50:27 -07:00