Skip to content

feat(auth): reset a forgotten password by email - #156

Merged
kymanirjarrett merged 4 commits into
mainfrom
feat/147-password-reset
Nov 30, 2026
Merged

kymanirjarrett merged 4 commits into
mainfrom
feat/147-password-reset

Conversation

@kymanirjarrett

Copy link
Copy Markdown
Owner

Closes #147

Backend

  • POST /api/auth/forgot-password always answers 202, whether or not the email has an account. The email is sent on its own background thread, so the response time doesn't reveal it either.
  • POST /api/auth/reset-password sets the new password (same rules as sign-up). Returns 204, or 400 for an invalid, used, or expired link.
  • V8 migration: password_reset_tokens stores only a SHA-256 hash of each 32-byte random token. Tokens expire in 30 minutes, work once, and a newer link replaces older ones. users.password_changed_at is added too.
  • Signing out everywhere: access tokens now carry a password-version claim (pwv). The decoder rejects any token whose version no longer matches the user's, so a reset ends every existing session. This replaces an iat comparison, which missed sessions created in the same second as the reset; the integration test caught it.
  • Rate limits: one per-IP budget for both endpoints (5 an hour), plus a silent cap on reset emails per address.
  • Email goes through Brevo's SMTP relay via spring-boot-starter-mail, prod profile only. Port 2525 is used because Render's free tier blocks outbound 25, 465, and 587. Locally and in tests, LoggingEmailSender prints the link instead.

Frontend

  • "Forgot your password?" link on login, /forgot-password, and /reset-password. The reset page removes the token from the address bar, and a successful reset returns to login with a confirmation.

Before this works in production: create a Brevo account, verify a sender address, and set MAIL_FROM, MAIL_USERNAME, and MAIL_PASSWORD in Render (APP_URL is set in render.yaml).

Checked: backend mvnw verify (new integration and rate-limit tests), frontend 68/68 tests and build, and the full flow by hand against a local API.

@kymanirjarrett
kymanirjarrett merged commit b1bd6ea into main Nov 30, 2026
6 checks passed
@kymanirjarrett
kymanirjarrett deleted the feat/147-password-reset branch November 30, 2026 02:20
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.

Password reset by email

1 participant