feat: 邮箱校验属性变更

feat/uniplus
moonrailgun 2 years ago
parent e78f10a69c
commit ce97957fa9

@ -106,7 +106,7 @@ export class User extends TimeStamps implements Base {
@prop({ @prop({
default: false, default: false,
}) })
emailAvailable: boolean; emailVerified: boolean;
/** /**
* *

@ -336,6 +336,7 @@ class UserService extends TcService {
nickname nickname
); );
let emailVerified = false;
if (config.emailVerification === true) { if (config.emailVerification === true) {
// 检查OTP // 检查OTP
const cacheKey = this.buildVerifyEmailKey(params.email); const cacheKey = this.buildVerifyEmailKey(params.email);
@ -344,6 +345,8 @@ class UserService extends TcService {
if (String(cachedOtp) !== params.emailOTP) { if (String(cachedOtp) !== params.emailOTP) {
throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP')); throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP'));
} }
emailVerified = true;
} }
const password = await this.hashPassword(params.password); const password = await this.hashPassword(params.password);
@ -352,6 +355,7 @@ class UserService extends TcService {
password, password,
nickname, nickname,
discriminator, discriminator,
emailVerified,
avatar: null, avatar: null,
createdAt: new Date(), createdAt: new Date(),
}); });
@ -449,6 +453,8 @@ class UserService extends TcService {
if (String(cachedOtp) !== params.emailOTP) { if (String(cachedOtp) !== params.emailOTP) {
throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP')); throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP'));
} }
user.emailVerified = true;
} }
await this.validateRegisterParams(params, t); await this.validateRegisterParams(params, t);

Loading…
Cancel
Save