Skip to content

Commit

Permalink
issue #36 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
igoshev committed Jan 3, 2020
1 parent e19cebe commit b78b10a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Captcha/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

class Captcha
{
/**
* @var string
*/
private $correctCode;

/**
* @var CodeInterface
*/
Expand Down Expand Up @@ -83,7 +88,7 @@ public function getImage()
*/
public function validate($code)
{
$correctCode = $this->storage->pull();
$correctCode = $this->getCorrectCode();

if (! empty($correctCode)) {
return mb_strtolower($correctCode) === mb_strtolower($code);
Expand All @@ -107,4 +112,16 @@ public function getView()
'input_id' => config('bone.captcha.inputId'),
]);
}

/**
* @return null|string
*/
protected function getCorrectCode()
{
if (! isset($this->correctCode)) {
$this->correctCode = $this->storage->pull();
}

return $this->correctCode;
}
}

0 comments on commit b78b10a

Please sign in to comment.