refactor: 增加验证超时时间

This commit is contained in:
Ying
2022-08-22 11:38:13 +08:00
parent ad639339cb
commit 6e1b38a34b
2 changed files with 14 additions and 2 deletions

View File

@@ -40,6 +40,12 @@ class Email
*/ */
private $userVModel; private $userVModel;
/**
* 验证码过期时间
* @var string
*/
private $expireTime = 5; //验证码过期时间(分钟)
/** /**
* 错误信息 * 错误信息
* @var string * @var string
@@ -265,7 +271,7 @@ class Email
// 是否过期 // 是否过期
$expires = time() - strtotime($result['create_time']); $expires = time() - strtotime($result['create_time']);
if ($expires <= 60) { if ($expires <= $this->expireTime * 60) {
return true; return true;
} }

View File

@@ -33,6 +33,12 @@ class Sms
protected $smsType = 'alisms'; protected $smsType = 'alisms';
/**
* 验证码过期时间
* @var string
*/
private $expireTime = 5; //验证码过期时间(分钟)
/** /**
* 类构造函数 * 类构造函数
* class constructor. * class constructor.
@@ -134,7 +140,7 @@ class Sms
$result->status = 0; $result->status = 0;
$result->save(); $result->save();
$expires = time() - strtotime($result['create_time']); $expires = time() - strtotime($result['create_time']);
if ($expires <= 60) { if ($expires <= $this->expireTime * 60) {
return true; return true;
} }
$this->setError("当前验证码已过期!"); $this->setError("当前验证码已过期!");