perf: 邮箱验证优化流程提示

This commit is contained in:
韦荣超 2022-03-07 14:38:40 +08:00
parent c1bdd079cf
commit a9f28dfb47
3 changed files with 16 additions and 7 deletions

View File

@ -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'])

View File

@ -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('邮箱地址已存在');
}
//密码

View File

@ -8,9 +8,7 @@
<p>{{$L('今后您可以通过此邮箱重置您的账号密码')}}</p>
</div>
<div class="validation-text" v-if="error">
<div>{{$L('您的邮箱未通过验证,可能的原因:')}}</div>
<div>{{$L('1.验证码已过期')}}</div>
<div>{{$L('2.重复使用验证码')}}</div>
<div>{{$L('链接已过期,请重新发送')}}</div>
</div>
<div slot="footer" v-if="success">
<Button type="primary" @click="userLogout" long>{{$L('返回首页')}}</Button>
@ -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)