mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-25 04:07:17 +08:00
修正验证登录空口令问题
This commit is contained in:
parent
22bab22ed1
commit
e32579ab6e
@ -51,6 +51,8 @@ class Verify extends Service
|
||||
|
||||
$value = $this->cache->get($key);
|
||||
|
||||
if (empty($value)) return false;
|
||||
|
||||
return $code == $value;
|
||||
}
|
||||
|
||||
@ -60,6 +62,8 @@ class Verify extends Service
|
||||
|
||||
$value = $this->cache->get($key);
|
||||
|
||||
if (empty($value)) return false;
|
||||
|
||||
return $code == $value;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,10 @@ class Verify extends Validator
|
||||
|
||||
public function checkSmsCode($phone, $code)
|
||||
{
|
||||
if (empty($code)) {
|
||||
throw new BadRequestException('verify.invalid_sms_code');
|
||||
}
|
||||
|
||||
$service = new VerifyService();
|
||||
|
||||
$result = $service->checkSmsCode($phone, $code);
|
||||
@ -56,6 +60,10 @@ class Verify extends Validator
|
||||
|
||||
public function checkMailCode($email, $code)
|
||||
{
|
||||
if (empty($code)) {
|
||||
throw new BadRequestException('verify.invalid_mail_code');
|
||||
}
|
||||
|
||||
$service = new VerifyService();
|
||||
|
||||
$result = $service->checkMailCode($email, $code);
|
||||
@ -65,28 +73,4 @@ class Verify extends Validator
|
||||
}
|
||||
}
|
||||
|
||||
public function checkRand($rand)
|
||||
{
|
||||
list($time, $number) = explode('-', $rand);
|
||||
|
||||
if (abs($time - time()) > 300) {
|
||||
throw new BadRequestException('verify.invalid_rand');
|
||||
}
|
||||
|
||||
if ($number < 1000 || $number > 9999) {
|
||||
throw new BadRequestException('verify.invalid_rand');
|
||||
}
|
||||
|
||||
return $rand;
|
||||
}
|
||||
|
||||
public function checkTicket($ticket, $rand)
|
||||
{
|
||||
$ticket = $this->crypt->decrypt($ticket);
|
||||
|
||||
if ($ticket != $rand) {
|
||||
throw new BadRequestException('verify.invalid_ticket');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user