Remove vestigial `username` field from auth/users (collision footgun, no functional purpose)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- authentication, database
Línea de trabajo
Start in packages/core/src/services/auth-validation.ts and packages/core/src/auth/config.ts to see how username is derived from the email at registration, then check the invitation-accept check in packages/core/src/routes/auth.ts. Phase 1 is a migration that drops the UNIQUE and NOT NULL constraints on users.username plus removing the invitation requirement; confirm with maintainers before attempting Phase 2, which is a multi-file column removal. Done means signup no longer fails on duplicate derived usernames and the invitation flow no longer requires a username.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
users.username is vestigial under the current email-based auth. It is not a login credential, it's auto-derived from the email when not supplied, and its only enforced behavior (NOT NULL UNIQUE) is a liability that causes spurious signup failures. It should be removed in the near future.
What username does today
- Not a login credential. Login is email-only everywhere —
loginSchemais{ email, password }(packages/core/src/routes/auth.ts) and Better Auth usessignInEmail. There is no path to sign in with a username. - Auto-derived, not chosen. On registration it is
.optional()(packages/core/src/services/auth-validation.ts); when omitted it is generated from the email local-part:email.split('@')[0](fallbackuser<timestamp>). The Better Auth create hook does the same (packages/core/src/auth/config.ts). In practice nobody enters it. - Display handle only, largely redundant with
email+first_name/last_name(shown inadmin-userslist/profile).
Why it exists
Legacy CMS convention (username-based logins / @handles). The users.username TEXT NOT NULL UNIQUE column was kept and still populated after login moved to email.
The problem (why this matters)
- Collision trap.
NOT NULL UNIQUE+ email-derived default means[email protected]and[email protected]both deriveusername = "alice", so the second registration fails with "User with this email or username already exists" — for a field the user never set and cannot see. Different people, different emails, blocked signup. - Inconsistency. Public registration treats username as optional/auto-derived, but the invitation-accept flow explicitly requires the user to type one (
if (!token || !username …) → error, with its own uniqueness check) —packages/core/src/routes/auth.ts.
Proposed removal plan
Phase 1 (low-risk, do soon):
- Drop the
UNIQUE(and ideallyNOT NULL) constraint onusers.username(migration). - Stop requiring it in the invitation-accept flow.
- This alone removes the signup-failure footgun.
Phase 2 (clean removal):
- Drop the column entirely; remove it from registration, invitation, admin user UI, and the Better Auth
additionalFields. - Touches ~35 files (templates,
admin-users, invitation flow, schema) + a schema migration.
Notes
- Pairs naturally with the broader legacy-auth cleanup (e.g. retiring the compatibility
users.rolecolumn). - Keep
usernameonly if a public@handleprofile feature is on the roadmap; otherwise it is dead weight.
Filed from analysis on branch feature/better-auth-poc.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.8k
- Forks
- 219
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 67
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de SonicJs-Org/sonicjs
-
bug(admin/users): server error returns bare alert HTML causing black-shape visual artifactPosiblemente ocupada @lane711 la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
SonicJs-Org/sonicjs#1211 ·
Los mantenedores suelen responder en 1 día
-
area: api bug priority: P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
SonicJs-Org/sonicjs#1200 ·
Los mantenedores suelen responder en 1 día
-
ResendProvider cannot send on Workers: unbound `fetch` stored as an instance property throws "Illegal invocation"Posiblemente ocupada @lane711 la tomó hace 23 días. Abiertoarea: email bug priority: P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SonicJs-Org/sonicjs#1099 ·
Los mantenedores suelen responder en 1 día
-
Email plugin settings are never read: loadDbEmailSettings queries a v2 `plugins` table that does not exist in v3Posiblemente ocupada @lane711 la tomó hace 23 días. Abiertoarea: email bug priority: P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
SonicJs-Org/sonicjs#1098 ·
Los mantenedores suelen responder en 1 día
-
area: documentation bug documentation priority: P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SonicJs-Org/sonicjs#1012 ·
Los mantenedores suelen responder en 1 día
Todos los issues de SonicJs-Org/sonicjs
Issues similares
-
awaiting-final-review request-icon
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
homebridge/plugins#1376 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mindfold-ai/Trellis#672 ·
-
p1 state:active track
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
StellarCanary/ProtocolCanary-Action#698 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pear-devs/pear-desktop#4839 ·
Los mantenedores suelen responder en 1 día