feat: a new account is confirmed with a code sent to its e-mail
All checks were successful
Build and deploy / Validate source (push) Successful in 17s
Build and deploy / Integration suite on a real stack (push) Successful in 4m25s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m22s
All checks were successful
Build and deploy / Validate source (push) Successful in 17s
Build and deploy / Integration suite on a real stack (push) Successful in 4m25s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m22s
Anyone could open an account on someone else's e-mail. Now "Criar conta" e-mails a 6-digit code, and the account exists only once it is entered: one big field that takes a paste or the phone's autofill and confirms by itself, "Reenviar código" after 60 s, "Trocar e-mail", and the sign-in box hidden meanwhile. Security: 15 minutes per code, 5 wrong attempts, at most 5 codes, limits per address and per source; the password is hashed at the first step and the code stored only as a hash, its e-mail erased once sent. An address that already has an account gets the same answer on screen and a "você já tem conta" e-mail instead of a code, so the form does not reveal who is registered. Without e-mail (MAIL_ADAPTER=off) the account is created at once, as before. The browser test reads the code from a local-only endpoint that exists only where e-mail stays in the log. Tested: mail_test (wrong, locked, resent, expired codes, existing address, erasure after SMTP), the full suite and the browser test in a CI-style stack, and the screens in Brave on desktop and phone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -260,7 +260,7 @@ CREATE TABLE IF NOT EXISTS dtf_local.operator_machines (
|
||||
-- E-mail (app/mail.py): queued in the transaction that caused it, sent by the
|
||||
-- worker. A recovery message's text is erased once sent; the subject stays.
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.mail_queue (
|
||||
id bigserial PRIMARY KEY, kind text NOT NULL CHECK(kind IN ('reset','alert','test')),
|
||||
id bigserial PRIMARY KEY, kind text NOT NULL,
|
||||
to_addr text NOT NULL, subject text NOT NULL, body text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(), available_at timestamptz NOT NULL DEFAULT now(),
|
||||
attempts int NOT NULL DEFAULT 0, last_error text, sent_at timestamptz, failed_at timestamptz
|
||||
@@ -282,3 +282,18 @@ ALTER TABLE dtf_local.operators ADD COLUMN IF NOT EXISTS alerts boolean NOT NULL
|
||||
ALTER TABLE dtf_local.orders ADD COLUMN IF NOT EXISTS contact_since timestamptz;
|
||||
ALTER TABLE dtf_local.orders ADD COLUMN IF NOT EXISTS contact_by text;
|
||||
ALTER TABLE dtf_local.orders ADD COLUMN IF NOT EXISTS contact_note text;
|
||||
|
||||
-- E-mail kinds: a password-recovery link, a signup code, the notice that an
|
||||
-- account already exists, the team's alerts and a test.
|
||||
ALTER TABLE dtf_local.mail_queue DROP CONSTRAINT IF EXISTS mail_queue_kind_check;
|
||||
ALTER TABLE dtf_local.mail_queue ADD CONSTRAINT mail_queue_kind_check
|
||||
CHECK(kind IN ('reset','code','account','alert','test'));
|
||||
-- A signup waiting for its e-mail code. The account is created only when the
|
||||
-- code is entered; the password is already hashed and the code only hashed.
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.account_signups (
|
||||
id uuid PRIMARY KEY, email text NOT NULL, profile jsonb NOT NULL, password_hash text NOT NULL,
|
||||
code_hash text, created_at timestamptz NOT NULL DEFAULT now(), 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
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS account_signups_created ON dtf_local.account_signups(created_at);
|
||||
|
||||
Reference in New Issue
Block a user