diff --git a/app/Services/Verify.php b/app/Services/Verify.php index 36fc9fcc..d304cfb6 100644 --- a/app/Services/Verify.php +++ b/app/Services/Verify.php @@ -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; } diff --git a/app/Validators/Verify.php b/app/Validators/Verify.php index 3e991c4b..e4d2ab3d 100644 --- a/app/Validators/Verify.php +++ b/app/Validators/Verify.php @@ -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'); - } - } - }