Authenticates a user and returns an access token only when the account is allowed to log in.
- Internal invocation through dependency injection (Inversify).
| Name | Required | Type | Description |
|---|---|---|---|
dto |
Yes | object |
Authentication input DTO containing email and password. |
- The email must resolve to a stored user with a hashed password.
- The user must not be in
INCOMEstate. - Coaches with a current subscription in
suspended,expired, orcancelledstate must be denied. - Historical coaches without a subscription remain temporarily exempt.
- Loads the user with the stored password hash.
- Rejects missing users, missing passwords, and
INCOMEaccounts. - Verifies the submitted password.
- For coaches, loads the current subscription and blocks denied statuses while preserving the generic invalid-credentials response.
- Signs and returns the access token.
- Returns the access-token session payload.
- Logs execution errors through the logger service before normalization/rethrow.
- Throws
ERRORS.INVALID_CREDENTIALSfor invalid credentials, denied coach subscription statuses, andINCOMEusers. - Historical coaches with no subscription continue to authenticate normally.
- Normalizes unexpected failures to
ERRORS.AUTH_USECASE_FAIL.
bddServicecryptServicejwtServiceloggerService
api/src/usecases/auth/auth.usecase.tsapi/src/usecases/auth/__tests__/auth.usecase.spec.ts