feat(auth): 添加用户注册开关功能

- 在系统设置中新增 allowRegister 配置项控制用户注册
- 实现注册接口的开关检查机制
- 登录页面根据注册开关动态显示或隐藏注册选项
- 首次 Linux.do 登录创建用户时也受注册开关限制
- 更新系统配置文档说明新的认证配置项
This commit is contained in:
HouYunFei
2026-05-25 16:03:54 +08:00
parent 030541b99d
commit b8e50c10f6
7 changed files with 50 additions and 7 deletions
+7 -1
View File
@@ -36,7 +36,7 @@ const emptySettings: AdminSettings = {
systemPrompt: "",
allowCustomChannel: true,
},
auth: { linuxDo: { enabled: false } },
auth: { allowRegister: true, linuxDo: { enabled: false } },
},
private: { channels: [], promptSync: { enabled: true, cron: "*/5 * * * *" }, auth: { linuxDo: { clientId: "", clientSecret: "" } } },
};
@@ -371,6 +371,11 @@ export default function AdminSettingsPage() {
<Switch />
</Form.Item>
</Col>
<Col span={24}>
<Form.Item name={["public", "auth", "allowRegister"]} label="是否允许用户注册" extra="关闭后隐藏注册入口,注册接口也会拒绝新用户创建" valuePropName="checked">
<Switch />
</Form.Item>
</Col>
<Col span={24}>
<Typography.Title level={5}></Typography.Title>
<Table
@@ -689,6 +694,7 @@ function normalizePublicSetting(setting: Partial<AdminSettings["public"]> = {}):
modelCosts: normalizeModelCosts(setting.modelChannel?.modelCosts || []),
},
auth: {
allowRegister: setting.auth?.allowRegister !== false,
linuxDo: {
enabled: setting.auth?.linuxDo?.enabled === true,
},