You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eae4c89
Browse filesBrowse the repository at this point in the historyBrowse files
`RegisterDto` and `LoginDto` normalise input through class-transformer (the global `ValidationPipe` already runs with `transform: true`):
4
+
5
+
-`email`: Unicode NFKC normalisation, control characters removed, surrounding whitespace trimmed. The case is **not** changed, so existing accounts keep matching.
6
+
-`firstName` / `lastName`: additionally strip HTML tags and collapse whitespace.
7
+
- Passwords and tokens are never altered.
8
+
9
+
Sanitising happens before validation, so `" user@example.com "` is accepted as `user@example.com` and a name consisting only of tags becomes empty and fails `@IsNotEmpty`. Helpers live in `src/auth/sanitize.util.ts`.
The main `AuthController` operations now carry `@ApiOperation` summaries and `@ApiResponse` entries (success plus the documented 400/401/404/429 cases) so they appear described in Swagger: register, login, refresh, logout, logout-all, me, change-password, password-reset request/reset and verify-email.
4
+
5
+
Open the Swagger UI exposed by the app and look under the **Authentication** tag. Protected operations show the `access-token` bearer scheme through the existing `@ApiBearerAuth` decorators.
`changePassword` and `resetPassword` duplicated three blocks. They now share private helpers in `AuthService`:
4
+
5
+
-`assertPasswordMeetsPolicy` - complexity check, 400 listing the broken rules,
6
+
-`assertPasswordNotReused` - compares against recent hashes, 400 if reused,
7
+
-`recordPasswordHistory` - stores the new hash and trims history beyond the retention limit.
8
+
9
+
Behaviour, error messages and the transaction boundaries are unchanged; each method is roughly 25 lines shorter and the reuse and retention rules now live in one place.
`retryWithBackoff` (`src/auth/retry.util.ts`) retries a failing call with exponential backoff (doubling from the base delay, capped, with up to 50% jitter) and rethrows the last error when attempts run out or `isRetryable` says stop.
4
+
5
+
Used for:
6
+
7
+
- the reCAPTCHA verification request: up to 3 attempts, retried on network errors, `429` and `5xx` (other responses are final). If it still fails the existing behaviour applies (verification fails closed).
8
+
- sending the password reset email: up to 3 attempts, so a transient mail-provider error does not silently lose the email. Persistent failure still propagates as before.
9
+
10
+
Login and token operations are not retried: they are not idempotent from the caller's side and failures there are authoritative.
0 commit comments