fix(auth): let people register under their own name - #1228
Closed
ninja14696 wants to merge 1 commit into
Closed
Conversation
Registration derived the username from the display name in the browser — `displayName.toLowerCase().replace(/\s+/g, '')` — and the server then required `^[a-zA-Z0-9_]+$`. Any name carrying a character outside a-z was rejected: João, José, André, Luís, Antônio, Mônica, Inês. So were names over 20 characters. The 422 came back in English, naming a `username` field the person had never seen, on a form rendered in Portuguese. The handle is now generated server-side by generateUniqueUsername(), which already existed and already served the Google sign-in path. Two changes make it fit for everyone: Str::slug transliterates rather than discards, so "João" becomes "joao" instead of "joo"; and the base is truncated with room reserved for the disambiguating counter, so a long name cannot exceed the column. A name in a script with no Latin equivalent transliterates to nothing and falls through to the email prefix, which is the existing behaviour and registers fine. `username` stays accepted when explicitly supplied, so anyone choosing their own handle is unaffected. Nine cases pinned: accents, cedilla, umlaut, a 30-character name, Japanese, and two people who share a name. 386 tests pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VM3bUo411kUuZxq5r7x5Nr
arnonrdp
approved these changes
Sep 4, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O bug
O cadastro derivava o username do nome no navegador (
AuthModal.vue:224) e o servidor exigia^[a-zA-Z0-9_]+$(AuthController.php:166). Qualquer nome com caractere fora de a-z era rejeitado:João, José, André, Luís, Antônio, Mônica, Inês — nomes dos mais comuns do Brasil. E o 422 voltava em inglês, citando um campo
usernameque a pessoa nunca viu, num formulário em português.Quem entra pelo Google não era afetado: aquele fluxo já chamava
generateUniqueUsername.A correção
O handle passa a ser gerado no servidor pelo mesmo
generateUniqueUsernameque já servia o login Google. Duas mudanças o deixam adequado para qualquer idioma:Str::slugtranslitera em vez de descartar — "João" virajoao, nãojoocomo antes.Nome em alfabeto sem equivalente latino translitera para vazio e cai no prefixo do e-mail — comportamento que já existia e registra normalmente.
usernamecontinua aceito quando enviado explicitamente, então quem quiser escolher o próprio handle não é afetado.Testes
Nove casos fixados: acento, cedilha, trema, nome de 30 caracteres, japonês, e duas pessoas com o mesmo nome. 386 testes passando.
Nota
Não há registro de quantas pessoas tentaram se cadastrar e falharam por isso — o erro não era logado em lugar nenhum. Pode ter custado usuários por meses sem deixar rastro.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VM3bUo411kUuZxq5r7x5Nr