1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 12:05:39 +08:00

修正验证登录空口令问题

This commit is contained in:
xiaochong0302 2023-05-08 23:38:10 +08:00
parent 22bab22ed1
commit e32579ab6e
2 changed files with 12 additions and 24 deletions

View File

@ -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;
}

View File

@ -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');
}
}
}