fix: accounts confirmed more than a day ago also bring their orders
Some checks failed
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Failing after 4m2s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped

The signups that marked an account as confirmed are deleted after a day, so
an older account was left unconfirmed and brought nothing. The code e-mail
sent before the account existed stays in the queue and now counts too. A
password reset, whose link came by e-mail, also confirms the address and
brings the orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-16 15:51:25 -03:00
parent 1a7736dc8b
commit 4f49ace867
3 changed files with 14 additions and 3 deletions

View File

@@ -91,11 +91,15 @@ def recovery(tag):
with db.connect() as c:
# Only the token's hash is kept.
assert not c.execute('SELECT 1 FROM dtf_local.password_resets WHERE token_hash=%s', (token,)).fetchone()
# An account never confirmed: the reset link, sent to the address, confirms it.
c.execute('UPDATE dtf_local.accounts SET email_verified=false WHERE email=%s', (address,))
stranger.call('/account/reset', {'token': 'x' * 43, 'password': NEW_PASSWORD}, expected=400)
stranger.call('/account/reset', {'token': token, 'password': 'curta'}, expected=422)
assert stranger.call('/account/reset', {'token': token, 'password': NEW_PASSWORD})['customer']['mail'] == address
assert stranger.call('/account/me')['customer']['mail'] == address
with db.connect() as c:
assert c.execute('SELECT email_verified FROM dtf_local.accounts WHERE email=%s', (address,)).fetchone()['email_verified']
# Works once; the old password and the old sessions are gone.
stranger.call('/account/reset', {'token': token, 'password': NEW_PASSWORD}, expected=400)
elsewhere.call('/account/me', expected=401)