Skip to content

feat: email-only auth with username login - #83

Open
gdccyuen wants to merge 1 commit into
Ontos-AI:mainfrom
gdccyuen:feat/gdccyuen/email-only-auth-username-login
Open

feat: email-only auth with username login#83
gdccyuen wants to merge 1 commit into
Ontos-AI:mainfrom
gdccyuen:feat/gdccyuen/email-only-auth-username-login

Conversation

@gdccyuen

@gdccyuen gdccyuen commented Aug 1, 2026

Copy link
Copy Markdown

What

Restricts dashboard authentication to email/password only and makes username the login identifier instead of email.

  • Register with username + email + password (username becomes a real, unique identifier via the better-auth username() plugin)
  • Login with username + password (no more email login)
  • Removed: Google/GitHub OAuth, magic-link login, Apple login stub

Changes

Username login (better-auth username() plugin)

  • lib/auth.ts: added username({ minUsernameLength: 2 }) plugin
  • lib/better-auth-client.ts: added usernameClient()
  • lib/db/auth-schema.ts + drizzle/0010_wet_omega_red.sql: username (unique) + displayUsername columns on user
  • app/(auth)/register/page.tsx: registration now passes username to signUp.email
  • app/(auth)/login/_components/username-login-form.tsx (renamed from email-login-form.tsx): username + password fields only, password mode always on
  • app/(auth)/login/_hooks/use-login-actions.ts: signIn.username({ username, password })

Removed login methods

  • OAuth: socialProviders block (github/google) deleted from lib/auth.ts; oauth-buttons.tsx + social-login-buttons.tsx components deleted; app/(auth)/callback/{github,apple}/ deleted; GITHUB_CLIENT_*/GOOGLE_CLIENT_*/APPLE_CLIENT_ID env vars + config fields removed
  • Magic link: magicLink plugin removed from server + client; app/(auth)/callback/magic-link/ deleted; magic-link UI/hooks removed
  • Login page shell simplified: password is the only mode (the PASSWORD_LOGIN_ENABLED toggle indirection dropped from the UI — password login is now unconditional)

Settings

  • Profile field relabeled to "Display name" (still edits name); a separate editable username field was intentionally not added (scope)

i18n (en/zh)

  • Added username login label; removed OAuth/magic-link strings; settings now uses displayName

Notes

  • The jwt plugin is kept — it's required for the dashboard→API service JWT and the OAuth token flow for CLI/MCP clients
  • RESEND_* env vars are kept (still used for password-reset emails)
  • Existing users in other deployments will have NULL username; they must update via the profile/DB before logging in by username (new sign-ups are unaffected)
  • Migration is backward-compatible: nullable columns, only additive
  • Verified: pnpm type-check, pnpm test (108 passed), pnpm build

- Adopt better-auth username() plugin: real unique username column +
  displayUsername, signIn.username() for login
- Registration now sends username (in addition to name) to signUp.email
- Login form: username + password only (email field removed)
- Remove Google/GitHub OAuth (server config, env vars, UI components,
  callback routes) and magic-link login (plugin, client, UI)
- Remove Apple login stub (callback page + config flag)
- Settings: relabel profile field to Display name (still edits name)
- Migration: add username/displayUsername columns to user table
- i18n (en/zh): drop OAuth/magic-link strings, add displayName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant