[ADD] auth: self-service password reset (/auth/forgot-password)#180
Merged
Conversation
Partial unique index on lower(email) can raise UniqueViolation from create/update portal user; redirect to /users?error=email_exists instead of surfacing a 500.
beorngb
force-pushed
the
feat/forgot-password
branch
from
July 17, 2026 15:50
8b0e71e to
7f8ec17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the self-service password reset that the login page already linked to
(
/auth/forgot-passwordwas a dead link — 404).Flow
GET/POST /auth/forgot-password→ emails a one-time reset link that lands on theexisting
/auth/setup-passwordroute. Reuses the existing token infra(
generate_token(purpose="reset"), 1h TTL) and Gmail-MCP delivery.all lookup/token/email work in a
BackgroundTask, so timing doesn't revealwhether an address is registered.
defence, since the per-IP limit trusts a proxy header).
restores access, it never grants portal access to a bot-only account. 2FA is
untouched.
Also in here
lower(email)(migration013) so duplicate emailsare impossible; admin user create/update now handle the violation gracefully
(and the previously-silent error codes on that page now render).
generate_tokenused("used_at", "=", None), which is SQL= NULLandmatched nothing — prior tokens were never invalidated. Now
IS NULL.GRIDBEAR_BASE_URLinstead of the request host.setup_passwordform now shows the real min length (12, was a stale 8).send_invite_emailtakessubject/ttl_hours(invite callers unchanged).sys.modules["webauthn"] = MagicMock()stubleaked across the suite; now only stubs when genuinely absent.
Tests — unit (routes, rate limit, reset logic, email params) + integration
(migration/idempotency, duplicate-email rejection, token invalidation). Verified
end-to-end against a live instance.
Follow-ups (not blocking)
MIN_PASSWORD_LENGTHis 12 in auth routes but 8 in admin user routes._get_client_iptrusts rawX-Forwarded-For(weakens the per-IP limit).shared test DB; fine today, worth tightening if more integration tests share it.