Skip to content

[BE-134] JwtStrategy.validate() never checks user.isActive #1276

Description

@yusuftomilola

Overview

JwtStrategy.validate() (backend/src/auth/strategies/jwt.strategy.ts) looks up the user by payload.sub and returns them if found — it never checks user.isActive. UsersService.setActive(id, false) exists specifically to deactivate an account, but a deactivated user's still-unexpired access token continues to authenticate successfully against every guarded route until it naturally expires.

Tasks

  • Add an isActive check in validate(), throwing UnauthorizedException for a deactivated user.
  • Add a unit test: deactivate a user, then assert a previously-issued (mocked) token payload for that user is rejected.
  • Consider also revoking the refresh token hash on deactivation (setRefreshTokenHash(id, null)) so a deactivated user can't silently refresh either.

Acceptance Criteria

  • A deactivated user's existing access token is rejected on the very next authenticated request.
  • A deactivated user cannot obtain a new token pair via /auth/refresh.

Notes for Contributors

Comment below to be assigned.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions