feat: 手机号登录、邮箱验证码注册

This commit is contained in:
xiaojunnuo
2024-11-29 19:00:05 +08:00
parent 87bbf6f140
commit 7b55337c5e
55 changed files with 2150 additions and 337 deletions
@@ -12,7 +12,7 @@ export type RegisterReq = {
phoneCode?: string;
validateCode: string;
imageCode: string;
imgCode: string;
randomStr: string;
};
@@ -40,16 +40,17 @@ export class RegisterController extends BaseController {
}
if (body.type === 'username') {
if (sysPublicSettings.usernameRegisterEnabled) {
if (sysPublicSettings.usernameRegisterEnabled === false) {
throw new Error('当前站点已禁止用户名注册功能');
}
await this.codeService.checkCaptcha(body.randomStr, body.imgCode);
const newUser = await this.userService.register(body.type, {
username: body.username,
password: body.password,
} as any);
return this.ok(newUser);
} else if (body.type === 'mobile') {
if (sysPublicSettings.mobileRegisterEnabled) {
if (sysPublicSettings.mobileRegisterEnabled === false) {
throw new Error('当前站点已禁止手机号注册功能');
}
//验证短信验证码