Skip to content

Commit 8a4ebee

Browse files
committed
fixed bug
1 parent 5e2ac7d commit 8a4ebee

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Core/ReCaptchaResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct($data, $ip, $message = '')
3131
$this->hostname = isset($data['hostname']) ? $data['hostname'] : '';
3232
$this->errorCodes = isset($data['error-codes']) ? $data['error-codes'] : [];
3333
$this->ip = $ip;
34-
$this->message = $message;
34+
$this->message = $this->errorCodes ? $this->errorCodes[0] : '';
3535
}
3636

3737
/**

src/GoogleReCaptcha.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function getView()
7272
public function verifyResponse($response, $ip = null)
7373
{
7474

75-
if ($this->config->isServiceEnabled()) {
75+
if (!$this->config->isServiceEnabled()) {
7676
$res = new ReCaptchaResponse([], $ip);
7777
$res->setSuccess(true);
7878
return $res;
@@ -102,6 +102,10 @@ public function verifyResponse($response, $ip = null)
102102
$decodedResponse = json_decode($verifiedResponse, true);
103103
$rawResponse = new ReCaptchaResponse($decodedResponse, $ip);
104104

105+
if ($rawResponse->isSuccess() === false) {
106+
return $rawResponse;
107+
}
108+
105109
if (strcasecmp($this->config->getHostName(), $rawResponse->getHostname()) !== 0) {
106110
$rawResponse->setMessage('Hostname does not match.');
107111
$rawResponse->setSuccess(false);

src/Validations/GoogleReCaptchaValidationRule.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
namespace RyanDeng\GoogleReCaptcha\Validations;
1010

1111

12-
use RyanDeng\GoogleReCaptcha\GoogleReCaptcha;
1312
use Illuminate\Contracts\Validation\ImplicitRule;
1413

15-
14+
use \RyanDeng\GoogleReCaptcha\Facades\GoogleReCaptcha;
1615
class GoogleReCaptchaValidationRule implements ImplicitRule
1716
{
1817
protected $action;

0 commit comments

Comments
 (0)