oliver-zehentleitner / maity
clean-up: one implementation of single-use mail links (item 1 of tsk-f5sdcgr7vzj0)
tsk-pfjwgw5e94k1 Done An agent
Item 1 of tsk-f5sdcgr7vzj0, split out: items 2 (#1831) and 3 (#1824) are merged, and that card is closed. Start after #1797 (tsk-q4zynccy5t0b) is merged. Separate PR; it touches single-use rules, so keep behaviour unchanged and cover both link kinds in tests.
1. One implementation of single-use mail links (audit #4)
- Files:
auth/email_links.py:issue:67,live:126,use:142,void_human:193,void_open:201,RequestLimits:238-256.auth/password_resets.py:issue:39,live:109,use:122,void_human:189,void_open:199,RequestLimits:158-175.- What is wrong:
issuehas the same shape in both: lock the human, return None if a newer row from the same source exists, void the earlier unused row from that source, insert.use,void_humanandvoid_opendiffer only in the table.- The two
RequestLimitsclasses are identical apart from the limiter names. password_resetsborrowsdigestandlock_humanfromemail_links.- Proposal: one shared module, for example
auth/single_use.py, with the table as a parameter, plus oneRequestLimits(prefix). The extras stay in their own modules: the sign-in code MAC and per-day counter, and the reset token. - Effort: M
- Risk: medium. These are race-sensitive single-use rules; the existing tests for both flows must stay green.
Notes
An agent · Nov 18, 2026, 14:42 UTC
Carry-over from PR #1797 (review A1273, 47me, optional P3; agreed with lotse, seq 162370): four wording fixes, no behaviour change.
docs/api.md(§2.6.4, near line 2129 at a16cf223): "Like every limit here these count requests when they are answered" should say "Like the pair and source limits", since the instance cap is counted when the outbox admits a mail.hub/src/maity_hub/auth/email_links.py(around line 229): "Mails one address is sent in answer to anonymous requests" should use the queued / request-time wording.hub/src/maity_hub/auth/email_links.py(around line 296): "suppress delivery" should become "nothing is queued".hub/src/maity_hub/notifications/preferences.py(around line 695): "no mail is sent" should become "no mail is queued".
Line numbers are as of #1797's head and may shift after its merge.