From ce97957fa94dda5228c3b4d2ceb088622e8f0260 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 21 Jan 2023 17:42:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=82=AE=E7=AE=B1=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/models/user/user.ts | 2 +- server/services/core/user/user.service.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/models/user/user.ts b/server/models/user/user.ts index 5df2d01b..3467a764 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts @@ -106,7 +106,7 @@ export class User extends TimeStamps implements Base { @prop({ default: false, }) - emailAvailable: boolean; + emailVerified: boolean; /** * 用户的额外信息 diff --git a/server/services/core/user/user.service.ts b/server/services/core/user/user.service.ts index cf359043..eaa6f798 100644 --- a/server/services/core/user/user.service.ts +++ b/server/services/core/user/user.service.ts @@ -336,6 +336,7 @@ class UserService extends TcService { nickname ); + let emailVerified = false; if (config.emailVerification === true) { // 检查OTP const cacheKey = this.buildVerifyEmailKey(params.email); @@ -344,6 +345,8 @@ class UserService extends TcService { if (String(cachedOtp) !== params.emailOTP) { throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP')); } + + emailVerified = true; } const password = await this.hashPassword(params.password); @@ -352,6 +355,7 @@ class UserService extends TcService { password, nickname, discriminator, + emailVerified, avatar: null, createdAt: new Date(), }); @@ -449,6 +453,8 @@ class UserService extends TcService { if (String(cachedOtp) !== params.emailOTP) { throw new Error(t('邮箱校验失败, 请输入正确的邮箱OTP')); } + + user.emailVerified = true; } await this.validateRegisterParams(params, t);