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

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:
Cauê Faleiros
2026-10-14 15:18:37 -03:00
parent 5a431f8422
commit 95be624cca
14 changed files with 337 additions and 29 deletions

View File

@@ -66,7 +66,20 @@
<input id="register-email" type="email" autocomplete="email" required>
<label for="register-password">Senha <span class="obs">12 caracteres ou mais</span></label>
<input id="register-password" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
<button class="bPri">Criar conta</button>
<button class="bPri" id="criarConta">Criar conta</button>
</form>
<!-- Takes the place of "Criar conta" while the e-mail is confirmed. -->
<form class="bloco" id="fCodigo" hidden>
<h2>Confirme seu e-mail</h2>
<p class="nota2">Enviamos um código de 6 números para <b id="codigoMail"></b>. Ele vale por <span id="codigoMin">15</span> minutos.</p>
<label for="codigo">Código</label>
<input id="codigo" class="codigo" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required>
<button class="bPri" id="codigoOk">Confirmar e criar conta</button>
<div class="codigoAcoes">
<button type="button" class="bLink" id="reenviar" disabled>Reenviar código</button>
<button type="button" class="bLink" id="trocarMail">Trocar e-mail</button>
</div>
<p class="nota2">Não chegou? Confira a caixa de spam.</p>
</form>
</div>
</section>