feat: 注册验证码改为自动生成图形验证码

1. Common.php: 新增captcha()接口,生成算术验证码图片(base64)
2. Common.php: 新增checkCaptcha()静态方法,验证码校验+防重放
3. User.php: 注册接口移除邮箱/短信OTP验证,改用图形验证码
验证码5分钟过期,验证后立即销毁
This commit is contained in:
li
2026-03-31 10:53:33 +08:00
parent 6a8ab13b7f
commit 733982a2be
2 changed files with 97 additions and 8 deletions
+10 -8
View File
@@ -141,21 +141,23 @@ class User extends Api
$mobile = $this->request->post('mobile',"");
$m_prefix = $this->request->post('m_prefix',"");
$code = $this->request->post('code');
$captcha_key = $this->request->post('captcha_key', '');
$pwd2 = $this->request->post('pay_pwd');
$referral_code = $this->request->post('referral_code', '');
// 验证图形验证码(替代邮箱/短信OTP)
if (!$captcha_key || !$code) {
$this->error(__('验证码错误'));
}
$captchaOk = \app\api\controller\Common::checkCaptcha($captcha_key, $code);
if (!$captchaOk) {
$this->error(__('验证码错误'));
}
if($mobile){
$ret = Sms::check($mobile, $code, 'register');
if (!$ret && $code!=157258) {
$this->error(__('验证码错误'));
}
$username = $mobile;
$extend['m_prefix'] = $m_prefix;
}else{
$ret = Ems::check($email, $code, 'register');
if (!$ret && $code!=157258) {
$this->error(__('验证码错误'));
}
$username = $email;
$extend['m_prefix'] = "";
}