perf: 注册时支持填写用户名

v2
xiaojunnuo 2025-08-07 10:36:34 +08:00
parent 06d166d0d7
commit fdcfcc77a0
2 changed files with 13 additions and 3 deletions

View File

@ -32,6 +32,13 @@
</a-tab-pane>
<a-tab-pane key="email" tab="邮箱注册" :disabled="!settingsStore.sysPublic.emailRegisterEnabled">
<template v-if="registerType === 'email'">
<a-form-item required has-feedback name="username" label="用户名">
<a-input v-model:value="formState.username" placeholder="用户名" size="large" autocomplete="off">
<template #prefix>
<fs-icon icon="ion:person-outline"></fs-icon>
</template>
</a-input>
</a-form-item>
<a-form-item required has-feedback name="email" label="邮箱">
<a-input v-model:value="formState.email" placeholder="邮箱" size="large" autocomplete="off">
<template #prefix>

View File

@ -40,6 +40,10 @@ export class RegisterController extends BaseController {
throw new Error('当前站点已禁止自助注册功能');
}
if (!body.username && body.username in ["admin","certd"]) {
throw new Error('用户名不能为保留字');
}
if (body.type === 'username') {
if (sysPublicSettings.usernameRegisterEnabled === false) {
throw new Error('当前站点已禁止用户名注册功能');
@ -47,9 +51,7 @@ export class RegisterController extends BaseController {
if (!body.username) {
throw new Error('用户名不能为空');
}
if (body.username in ["admin","certd"]) {
throw new Error('用户名不能为保留字');
}
await this.codeService.checkCaptcha(body.randomStr, body.imgCode);
const newUser = await this.userService.register(body.type, {
username: body.username,
@ -70,6 +72,7 @@ export class RegisterController extends BaseController {
throwError: true,
});
const newUser = await this.userService.register(body.type, {
username: body.username,
phoneCode: body.phoneCode,
mobile: body.mobile,
password: body.password,