fix: accounts confirmed more than a day ago also bring their orders
Some checks failed
Some checks failed
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:
@@ -394,13 +394,16 @@ def reset_password(body: PasswordReset, request: Request, response: Response):
|
||||
raise HTTPException(400, 'Este link venceu ou já foi usado. Peça outro em “Esqueci minha senha”.')
|
||||
identity = reset['account_id']
|
||||
account = account_row(c, identity, lock=True)
|
||||
c.execute('UPDATE dtf_local.accounts SET password_hash=%s WHERE id=%s', (password_hash(body.password), identity))
|
||||
# The link came by e-mail, so the address is confirmed too.
|
||||
c.execute('UPDATE dtf_local.accounts SET password_hash=%s, email_verified=true WHERE id=%s',
|
||||
(password_hash(body.password), identity))
|
||||
c.execute('UPDATE dtf_local.password_resets SET used_at=now() WHERE token_hash=%s', (digest,))
|
||||
# Every other link to this account stops working, and so does every
|
||||
# session signed in with the old password.
|
||||
c.execute('DELETE FROM dtf_local.password_resets WHERE account_id=%s AND used_at IS NULL', (identity,))
|
||||
if previous:
|
||||
transfer_guest(c, previous, identity)
|
||||
claim_orders(c, identity, account['profile'])
|
||||
c.execute('DELETE FROM dtf_local.sessions WHERE owner=%s', (identity,))
|
||||
if previous:
|
||||
c.execute('DELETE FROM dtf_local.sessions WHERE id=%s', (previous['id'],))
|
||||
|
||||
Reference in New Issue
Block a user