Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanDaDeng committed Aug 12, 2020
2 parents b0f5762 + e67babb commit fd8e61d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ This package requires the following dependencies:
Via Composer

``` sh
$ composer require timehunter/laravel-google-recaptcha-v3 "~2.3.1" -vvv
$ composer require timehunter/laravel-google-recaptcha-v3 "~2.4.0" -vvv
```

If your Laravel framework version <= 5.4, please register the service provider under your config file: /config/app.php, otherwise please skip it.
Expand Down Expand Up @@ -572,6 +572,7 @@ Thank you for the following contributors, You guys are the BEST!
* [@demiurge-ash](https://github.com/demiurge-ash)
* [@lxlang](https://github.com/lxlang)
* [@Indianos](https://github.com/Indianos)
* [@ericp-mrel](https://github.com/ericp-mrel)

## Security

Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
'ERROR_SCORE_THRESHOLD' => 'Score does not meet threshold.',
'ERROR_TIMEOUT' => 'Timeout',
'SUCCESS' => 'Successfully passed.',
'TIMEOUT_OR_DUPLICATE'=> 'The action is timeout.'
'TIMEOUT_OR_DUPLICATE'=> 'The action is timeout.',
];
2 changes: 1 addition & 1 deletion resources/lang/lv/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
'ERROR_SCORE_THRESHOLD' => 'Vērtējums neatbilst minimālajam slieksnim.',
'ERROR_TIMEOUT' => 'Noildze',
'SUCCESS' => 'Veiksmīgi apstiprināts.',
'TIMEOUT_OR_DUPLICATE'=> 'Noildze'
'TIMEOUT_OR_DUPLICATE'=> 'Noildze',
];
2 changes: 1 addition & 1 deletion resources/lang/ru/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
'ERROR_SCORE_THRESHOLD' => 'Оценка не соответствует пороговому значению.',
'ERROR_TIMEOUT' => 'Тайм-аут',
'SUCCESS' => 'Проверка успешно пройдена.',
'TIMEOUT_OR_DUPLICATE' => 'Тайм-аут'
'TIMEOUT_OR_DUPLICATE' => 'Тайм-аут',
];
13 changes: 7 additions & 6 deletions resources/views/googlerecaptchav3/template.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@if($display === false)
<style {!! $nonce !!}>
.grecaptcha-badge {
display: none;
visibility: hidden;
}
</style>
@endif
Expand Down Expand Up @@ -51,17 +51,18 @@ function onloadCallback() {
@endforeach
}
</script>
<script id='gReCaptchaScript' src="{{$apiJsUrl}}?render=explicit&onload=onloadCallback"
<script id='gReCaptchaScript' src="{{$apiJsUrl}}?render={{$inline ? 'explicit' : $publicKey}}&onload=onloadCallback"
defer
async {!! $nonce !!}></script>
@endif

<script {!! $nonce !!}>
function refreshReCaptchaV3(fieldId,action){
grecaptcha.reset(window['client'+fieldId]);
grecaptcha.ready(function () {
grecaptcha.execute(window['client'+fieldId], {
action: action
return new Promise(function (resolve, reject) {
grecaptcha.ready(function () {
grecaptcha.execute(window['client'+fieldId], {
action: action
}).then(resolve);
});
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/Services/GoogleReCaptchaV3Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function ifInSkippedIps($ip)
*/
public function verifyResponse($response, $ip = null)
{
if (!$this->config->isServiceEnabled() || ($ip && $this->ifInSkippedIps($ip)) === true) {
if (! $this->config->isServiceEnabled() || ($ip && $this->ifInSkippedIps($ip)) === true) {
$res = new GoogleReCaptchaV3Response([], $ip);
$res->setSuccess(true);

Expand Down Expand Up @@ -77,14 +77,15 @@ public function verifyResponse($response, $ip = null)

if ($rawResponse->getMessage() === 'timeout-or-duplicate') {
$rawResponse->setMessage(Lang::get(GoogleReCaptchaV3Response::TIMEOUT_OR_DUPLICATE));

return $rawResponse;
}

if ($rawResponse->isSuccess() === false) {
return $rawResponse;
}

if (!empty($this->config->getHostName()) && strcasecmp($this->config->getHostName(), $rawResponse->getHostname()) !== 0) {
if (! empty($this->config->getHostName()) && strcasecmp($this->config->getHostName(), $rawResponse->getHostname()) !== 0) {
$rawResponse->setMessage(Lang::get(GoogleReCaptchaV3Response::ERROR_HOSTNAME));
$rawResponse->setSuccess(false);

Expand Down

0 comments on commit fd8e61d

Please sign in to comment.