From a9f28dfb47760f0217140dc4207103e4e847d1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E8=8D=A3=E8=B6=85?= <302645122@qq.com> Date: Mon, 7 Mar 2022 14:38:40 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=82=AE=E7=AE=B1=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=81=E7=A8=8B=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UsersController.php | 4 +++- app/Models/User.php | 6 ++++++ resources/assets/js/pages/single/validEmail.vue | 13 +++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 19db72426..b2b507daf 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -602,12 +602,14 @@ class UsersController extends AbstractController } // 如果已经校验过 if (intval($res->status) === 1) - return Base::retError('链接已经使用过'); + return Base::retError('链接已经使用过',['code' => 2]); $oldTime = strtotime($res->created_at); $time = time(); //24个小时失效 if (abs($time - $oldTime) > 86400) { + $user = User::whereUserid($res->userid)->first(); + UserEmailVerification::userEmailSend($user); return Base::retError("链接已失效"); } UserEmailVerification::where('code', $data['code']) diff --git a/app/Models/User.php b/app/Models/User.php index b039e2cd3..97cdab565 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -187,6 +187,12 @@ class User extends AbstractModel throw new ApiException('请输入正确的邮箱地址'); } if (User::email2userid($email) > 0) { + $isRegVerify = Base::settingFind('emailSetting', 'reg_verify') === 'open' ? true : false; + $user = self::whereUserid(User::email2userid($email))->first(); + if ($isRegVerify && $user->is_email_verity === 0) { + UserEmailVerification::userEmailSend($user); + throw new ApiException('您的账号已注册过,请验证邮箱'); + } throw new ApiException('邮箱地址已存在'); } //密码 diff --git a/resources/assets/js/pages/single/validEmail.vue b/resources/assets/js/pages/single/validEmail.vue index 62d3a9f88..7c2dd05ce 100644 --- a/resources/assets/js/pages/single/validEmail.vue +++ b/resources/assets/js/pages/single/validEmail.vue @@ -8,9 +8,7 @@

{{$L('今后您可以通过此邮箱重置您的账号密码')}}

-
{{$L('您的邮箱未通过验证,可能的原因:')}}
-
{{$L('1.验证码已过期')}}
-
{{$L('2.重复使用验证码')}}
+
{{$L('链接已过期,请重新发送')}}
@@ -46,11 +44,14 @@ export default { .then(({data}) => { this.success = true; this.error = false; - }) - .catch(() => { + }).catch(({data, msg}) => { + if (data.code === 2) { + this.goForward({path: '/'}, true); + } else { this.success = false; this.error = true; - }); + } + }); }, userLogout() { this.$store.dispatch("logout", false)