mirror of https://github.com/certd/certd
chore:
parent
013b9c4c7c
commit
4019b7939a
|
@ -32,7 +32,7 @@
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="email" tab="邮箱注册" :disabled="!settingsStore.sysPublic.emailRegisterEnabled">
|
<a-tab-pane key="email" tab="邮箱注册" :disabled="!settingsStore.sysPublic.emailRegisterEnabled">
|
||||||
<template v-if="registerType === 'email'">
|
<template v-if="registerType === 'email'">
|
||||||
<a-form-item required has-feedback name="username" label="用户名">
|
<a-form-item required has-feedback name="username" label="用户名" :rules="rules.username">
|
||||||
<a-input v-model:value="formState.username" placeholder="用户名" size="large" autocomplete="off">
|
<a-input v-model:value="formState.username" placeholder="用户名" size="large" autocomplete="off">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<fs-icon icon="ion:person-outline"></fs-icon>
|
<fs-icon icon="ion:person-outline"></fs-icon>
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class RegisterController extends BaseController {
|
||||||
throw new Error('当前站点已禁止自助注册功能');
|
throw new Error('当前站点已禁止自助注册功能');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!body.username && body.username in ["admin","certd"]) {
|
if (body.username && ["admin","certd"].includes(body.username) ) {
|
||||||
throw new Error('用户名不能为保留字');
|
throw new Error('用户名不能为保留字');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ export class RegisterController extends BaseController {
|
||||||
throwError: true,
|
throwError: true,
|
||||||
});
|
});
|
||||||
const newUser = await this.userService.register(body.type, {
|
const newUser = await this.userService.register(body.type, {
|
||||||
|
username: body.username,
|
||||||
email: body.email,
|
email: body.email,
|
||||||
password: body.password,
|
password: body.password,
|
||||||
} as any);
|
} as any);
|
||||||
|
|
|
@ -175,25 +175,26 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
if (!user.password) {
|
if (!user.password) {
|
||||||
user.password = simpleNanoId();
|
user.password = simpleNanoId();
|
||||||
}
|
}
|
||||||
if (!user.username) {
|
|
||||||
user.username = 'user_' + simpleNanoId();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'username') {
|
|
||||||
|
if (user.username) {
|
||||||
const username = user.username;
|
const username = user.username;
|
||||||
const old = await this.findOne([{ username: username }, { mobile: username }, { email: username }]);
|
const old = await this.findOne([{ username: username }, { mobile: username }, { email: username }]);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
throw new CommonException('用户名已被注册');
|
throw new CommonException('用户名已被注册');
|
||||||
}
|
}
|
||||||
} else if (type === 'mobile') {
|
}
|
||||||
|
|
||||||
|
if (user.mobile) {
|
||||||
const mobile = user.mobile;
|
const mobile = user.mobile;
|
||||||
|
|
||||||
user.nickName = mobile.substring(0, 3) + '****' + mobile.substring(7);
|
user.nickName = user.username || mobile.substring(0, 3) + '****' + mobile.substring(7);
|
||||||
const old = await this.findOne([{ username: mobile }, { mobile: mobile }, { email: mobile }]);
|
const old = await this.findOne([{ username: mobile }, { mobile: mobile }, { email: mobile }]);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
throw new CommonException('手机号已被注册');
|
throw new CommonException('手机号已被注册');
|
||||||
}
|
}
|
||||||
} else if (type === 'email') {
|
}
|
||||||
|
if (user.email) {
|
||||||
const email = user.email;
|
const email = user.email;
|
||||||
const old = await this.findOne([{ username: email }, { mobile: email }, { email: email }]);
|
const old = await this.findOne([{ username: email }, { mobile: email }, { email: email }]);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
|
@ -201,6 +202,11 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!user.username) {
|
||||||
|
user.username = 'user_' + simpleNanoId();
|
||||||
|
}
|
||||||
|
|
||||||
let newUser: UserEntity = UserEntity.of({
|
let newUser: UserEntity = UserEntity.of({
|
||||||
username: user.username,
|
username: user.username,
|
||||||
password: user.password,
|
password: user.password,
|
||||||
|
|
Loading…
Reference in New Issue