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:
@@ -304,10 +304,14 @@ CREATE TABLE IF NOT EXISTS dtf_local.email_changes (
|
||||
sent_at timestamptz NOT NULL DEFAULT now(), expires_at timestamptz NOT NULL,
|
||||
sends int NOT NULL DEFAULT 1, attempts int NOT NULL DEFAULT 0, done_at timestamptz
|
||||
);
|
||||
-- Accounts confirmed by a code before email_verified existed.
|
||||
-- Accounts confirmed by a code before email_verified existed. The signups
|
||||
-- are deleted after a day; the code e-mail sent before the account existed
|
||||
-- stays in the queue.
|
||||
UPDATE dtf_local.accounts a SET email_verified=true WHERE NOT a.email_verified AND (
|
||||
EXISTS (SELECT 1 FROM dtf_local.account_signups s WHERE s.email=a.email AND s.done_at IS NOT NULL)
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.email_changes e WHERE e.account_id=a.id AND e.new_email=a.email AND e.done_at IS NOT NULL));
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.email_changes e WHERE e.account_id=a.id AND e.new_email=a.email AND e.done_at IS NOT NULL)
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.mail_queue m WHERE m.kind='code' AND lower(m.to_addr)=a.email
|
||||
AND m.created_at<=a.created_at));
|
||||
-- E-mail kinds: a password-recovery link, a code, the notice that an account
|
||||
-- already exists, the notice of a changed e-mail, the team's alerts and a test.
|
||||
-- Defined once, here: the schema runs on every start, and an earlier, narrower
|
||||
|
||||
Reference in New Issue
Block a user