Skip to content

[BE-79] Build the users module #1133

Description

@yusuftomilola

Overview

Users are the foundation for authentication, ownership, and RBAC. The frontend already has a users page and calls these endpoints.

API contract: the frontend already calls these endpoints — see frontend/lib/api/ and frontend/lib/query/keys.ts. Match the paths exactly so the existing UI works without changes.

GET   /users            list (paginated, searchable)
GET   /users/me         current user profile
PATCH /users/${id}/role     change a user's role

Tasks

  • Create the User entity: id, email (unique), passwordHash, firstName, lastName, role, departmentId, avatarUrl, isActive, lastLoginAt, timestamps.
  • Build module, service, and controller with full CRUD plus the endpoints above.
  • Hash passwords with bcrypt; never return passwordHash in any response (use a serializer or explicit select).
  • Add search and filtering by name, email, role, department, and active status.
  • Add deactivate/reactivate rather than hard delete, so historical asset assignments stay intact.
  • Generate a migration and write unit tests.

Acceptance Criteria

  • All three endpoints above work and match the frontend's expectations.
  • Password hashes never appear in a response (asserted by a test).
  • A user cannot change their own role through the profile update path.

Dependencies

Foundation from [BE-75]; RBAC roles from [BE-81].

Notes for Contributors

The backend is being rebuilt from a clean NestJS skeleton — backend/src/ currently contains only app.module.ts, app.controller.ts, app.service.ts, and main.ts. Follow standard NestJS module structure (module / controller / service / dto / entities) and register your module in app.module.ts. Comment below to be assigned.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions