Skip to content

feat(auth): 新增仅限邀请注册档位 - #3900

Merged
lyingbug merged 2 commits into
mainfrom
feat/invitation-registration-mode
Sep 30, 2026
Merged

lyingbug merged 2 commits into
mainfrom
feat/invitation-registration-mode

Conversation

@lyingbug

@lyingbug lyingbug commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

关闭公开注册后,邀请链接只显示登录表单,全新用户无法注册加入。新增「仅限邀请注册」档位,使持有效邀请链接的新用户可以注册并直接加入受邀空间。

注册模式 公开注册 有效邀请注册 已有账号接受邀请
self_serve(开放注册) 允许 允许 允许
invite_register(仅限邀请注册) 禁止 允许 允许
invite_only(禁止注册) 禁止 禁止 允许
  • 前后端统一执行三档策略;全局设置保存后立即生效。
  • 邀请页支持切换注册和登录,并加载当前密码策略。认证配置获取失败时隐藏注册入口。
  • 更新五种语言的设置文案、配置校验和认证文档。

兼容性变化: 保留现有配置值及 DISABLE_REGISTRATION=true → invite_only 的映射,但 invite_only 现在也会对 /auth/register-by-invite 返回 403。此前直接调用该接口注册的部署需要显式切换到 invite_register。OIDC 和管理员创建账号仍使用原有策略。

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🧪 Test

Related Issue

无。

Testing

  • go test ./internal/config ./internal/handler ./internal/application/service -run 'Test(Register|RegistrationMode|GetAuthConfig|ApplyAuthAndTenantDefaults|ValidateInvitationRegistrationMode|ValidateRegistrationModes|.*Accept.*Token)' -count=1
  • 在 frontend/ 执行:
    • npm test -- src/views/auth/registrationPolicy.test.ts src/i18n/localeKeyAudit.test.ts:18 项通过。
    • npm run type-check:通过。
    • npm run build:通过,有 chunk 大小提示。
  • git diff --check origin/main...HEAD:通过。
  • 使用与 CI 相同的 golangci-lint v2.12.2 运行 golangci-lint run --new-from-merge-base=9842e51d40a54ca2dbb61153f3fb587da1265b7a:通过,0 issues。
  • 未运行全仓库测试;验证范围为注册、邀请、设置、配置、多语言及前端类型检查和构建。

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

未附截图:本地未启动完整后端做浏览器联调。注册入口策略通过前端测试验证;合并前可在全局设置切换三档,并分别以新用户和已有账号打开有效邀请链接验收。

@lyingbug
lyingbug merged commit 5225edc into main Sep 30, 2026
6 checks passed
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