Skip to content

feat(auth): 支持用户名/工号登录 —— 接入 better-auth username 插件 #2756

Description

@baozhoutao

诉求

接入 better-auth 的 username 插件,支持用户名登录(/api/v1/auth/sign-in/username,可用用户名或邮箱登录)。

现状

plugin-auth 目前没接 username(),登录标识符只有邮箱(见 packages/plugins/plugin-auth/src/auth-manager.tsbuildPluginList())。而 better-auth@1.6.23 内置就有 username 插件(支持 displayUsernameisUsernameAvailable 查重),原生可用。

做法

  1. auth-manager.tsplugins.push(username({ schema: ... })),加 feature flag 门控(对齐现有 enabled.xxx 约定)。
  2. Schema 迁移:user 表加 username / display_username 列,snake_case 映射(参考现有 buildAdminPluginSchema())。
  3. 暴露到 /api/v1/auth/configfeatures,前端登录页据此支持"用户名或邮箱"输入(objectui 侧配合)。

属于改框架代码 + 迁移,非配置开关。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions