| xqd
@@ -334,19 +334,22 @@ class CommonController extends Controller
|
|
|
* Create By 2020/11/6 10:45
|
|
|
*/
|
|
|
public function putverfiy(){
|
|
|
+ //防止恶意刷验证码接口,一分钟最多10次
|
|
|
+ check_repeat_request(60, 10);
|
|
|
+
|
|
|
$req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
'phone|手机号' => 'required|integer',
|
|
|
]);
|
|
|
$mobile =$req['phone']; //获取传入的手机号
|
|
|
- $num = rand(1000,9999); //随机产生四位数字的验证码
|
|
|
- $verify_code = $num;
|
|
|
+ $verify_code = generate_code();
|
|
|
$texts = send_sms($mobile,'verify_template_code',['code'=>$verify_code]);
|
|
|
- if ($texts->Message=='OK'){
|
|
|
- return out($num);
|
|
|
- }else{
|
|
|
- return out('',500,'发送验证码错误');
|
|
|
+ if (empty($result['Code']) || $result['Code'] != 'OK'){
|
|
|
+ return out(null, 30010, '验证码发送失败,请稍后重试');
|
|
|
}
|
|
|
+ Cache::set($req['phone'].'-'.$req['type'], $verify_code, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
+
|
|
|
+ return out();
|
|
|
}
|
|
|
|
|
|
/**
|