...
|
...
|
@@ -14,7 +14,7 @@ class Sms |
|
|
* 验证码有效时长
|
|
|
* @var int
|
|
|
*/
|
|
|
protected static $expire = 120;
|
|
|
protected static $expire = 600;
|
|
|
|
|
|
/**
|
|
|
* 最大允许检测的次数
|
...
|
...
|
@@ -53,12 +53,12 @@ class Sms |
|
|
$time = time();
|
|
|
$ip = request()->ip();
|
|
|
$sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]);
|
|
|
$result = Hook::listen('sms_send', $sms, null, true);
|
|
|
if (!$result) {
|
|
|
$sms->delete();
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
// $result = Hook::listen('sms_send', $sms, null, true);
|
|
|
// if (!$result) {
|
|
|
// $sms->delete();
|
|
|
// return false;
|
|
|
// }
|
|
|
return $code;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -98,20 +98,23 @@ class Sms |
|
|
if ($sms['createtime'] > $time && $sms['times'] <= self::$maxCheckNums) {
|
|
|
$correct = $code == $sms['code'];
|
|
|
if (!$correct) {
|
|
|
$sms->times = $sms->times + 1;
|
|
|
$sms->save();
|
|
|
// $sms->times = $sms->times + 1;
|
|
|
// $sms->delete();
|
|
|
return false;
|
|
|
} else {
|
|
|
$result = Hook::listen('sms_check', $sms, null, true);
|
|
|
// $result = Hook::listen('sms_check', $sms, null, true);
|
|
|
$sms->times = 1;
|
|
|
$result = $sms->save();
|
|
|
return $result;
|
|
|
}
|
|
|
} else {
|
|
|
// 过期则清空该手机验证码
|
|
|
self::flush($mobile, $event);
|
|
|
return false;
|
|
|
return 2;
|
|
|
}
|
|
|
} else {
|
|
|
return false;
|
|
|
return \app\common\model\Sms::where(['mobile' => $mobile, 'event' => $event])
|
|
|
->order('id', 'DESC')->buildSql();
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|