Remove vestigial `username` field from auth/users (collision footgun, no functional purpose)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 1.8k
- フォーク
- 219
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 67
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SonicJs-Org/sonicjs のほかの issue
-
bug(admin/users): server error returns bare alert HTML causing black-shape visual artifact対応中かも @lane711 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SonicJs-Org/sonicjs#1211 ·
メンテナーはふだん 1 日以内に返信
-
area: api bug priority: P2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SonicJs-Org/sonicjs#1200 ·
メンテナーはふだん 1 日以内に返信
-
ResendProvider cannot send on Workers: unbound `fetch` stored as an instance property throws "Illegal invocation"対応中かも @lane711 が 23 日前に担当しました。 オープンarea: email bug priority: P1
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SonicJs-Org/sonicjs#1099 ·
メンテナーはふだん 1 日以内に返信
-
Email plugin settings are never read: loadDbEmailSettings queries a v2 `plugins` table that does not exist in v3対応中かも @lane711 が 23 日前に担当しました。 オープンarea: email bug priority: P1
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
SonicJs-Org/sonicjs#1098 ·
メンテナーはふだん 1 日以内に返信
-
area: documentation bug documentation priority: P2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SonicJs-Org/sonicjs#1012 ·
メンテナーはふだん 1 日以内に返信
SonicJs-Org/sonicjs の issue をすべて見る
似ている issue
-
awaiting-final-review request-icon
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
homebridge/plugins#1376 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mindfold-ai/Trellis#672 ·
-
p1 state:active track
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
StellarCanary/ProtocolCanary-Action#698 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pear-devs/pear-desktop#4839 ·
メンテナーはふだん 1 日以内に返信