Skip to content

Add role-based access control for admin role management - #1044

Merged
nafiuishaaq merged 7 commits into
MentoNest:mainfrom
Vox-d-glitch:issue-977-rbac
Aug 2, 2026
Merged

Add role-based access control for admin role management#1044
nafiuishaaq merged 7 commits into
MentoNest:mainfrom
Vox-d-glitch:issue-977-rbac

Conversation

@Vox-d-glitch

Copy link
Copy Markdown
Contributor

Adds the admin-facing pieces of RBAC on top of the existing roles table and guard:

  • POST /admin/users/:userId/roles and DELETE /admin/users/:userId/roles/:role, guarded by @Roles(AuthRole.ADMIN)
  • Role changes increment the user's tokenVersion so existing sessions are invalidated
  • RolesGuard now throws a ForbiddenException with a clear message instead of a generic 403
  • description column added to roles
  • UsersService.createUser assigns the mentee role by default for new accounts

Closes #977

Add an admin-only endpoint to assign and revoke user roles, a
description field on roles, and a clear 403 message when a caller
lacks a required role. Role changes bump the user's token version to
invalidate existing sessions. New users default to the mentee role.

Closes MentoNest#977
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@Vox-d-glitch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

# Conflicts:
#	backend/src/users/users.module.ts
#	backend/src/users/users.service.spec.ts
- auth.controller.ts had two full AuthController class bodies concatenated
  (a botched prior merge), which broke parsing for the whole file and
  cascaded into unrelated eslint type-resolution errors repo-wide
- add missing @nestjs/swagger dependency (used throughout but never
  added to package.json)
- fix relative import paths in auth.service.ts (an extra '../' pointed
  outside src/auth, breaking NodeNext module resolution)
- add .js extensions to relative imports per the project's nodenext
  moduleResolution, removing further unresolved-type cascades
- remove JwtAuthGuard's unresolvable third constructor parameter (a bare
  function type Nest can never inject), small unused-import/no-await
  cleanups, and a wrong TypeORM option name (connectTimeout -> connectTimeoutMS)
- apply repo-wide prettier formatting (was never run on ~50 files)

Lint: 95 errors -> 0. Build: failing -> passing. Prettier: 51 files -> 0.
…ation

These specs were written against a device-aware, RefreshTokenService +
UsersService backed refresh-token design that was never wired into
AuthService/AuthController — the real implementation still uses the
simpler in-memory nonce/token-map flow. Rewrite both specs to exercise
what's actually there instead of leaving them permanently red.
@nafiuishaaq

Copy link
Copy Markdown
Contributor

Please resolve conflict

@nafiuishaaq
nafiuishaaq merged commit da23d38 into MentoNest:main Aug 2, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Role-based access control (RBAC)

2 participants