Skip to content

Commit 02d0e70

Browse files
committed
UPDATED
1 parent 990435e commit 02d0e70

File tree

5 files changed

+19
-35
lines changed

5 files changed

+19
-35
lines changed

README.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
[![Latest Version on Packagist][ico-version]][link-packagist]
44
[![Total Downloads][ico-downloads]][link-downloads]
55

6-
STILL UNDER IMPLEMENTATION !!!
7-
86

97
Google reCAPTCHA v3 is a new mechanism to verify whether the user is bot or not.
108

@@ -58,7 +56,7 @@ If your Laravel framework version is >= 5.5, just run the following command to p
5856
$ php artisan vendor:publish --provider="RyanDeng\GoogleReCaptcha\Providers\GoogleReCaptchaV3ServiceProvider"
5957
```
6058

61-
After installation, you should see a googlerecaptcha/googlerecaptchav3.blade file in your views folder and googlerecaptchav3.php in your app/config folder.
59+
After installation, you should see a googlerecaptchav3/field.blade and header.blade file in your views folder and googlerecaptchav3.php in your app/config folder.
6260

6361
## Basic Usage
6462
#### Setting up your Google reCAPTCHA details in config file
@@ -69,7 +67,6 @@ Specify your Score threshold and action in 'setting', e.g.
6967
``` php
7068
'setting' = [
7169
'action' => 'contact_us', // Google reCAPTCHA required paramater
72-
'id' => 'contactus_id', // your HTML input field id
7370
'threshold' => 0.2, // score threshold
7471
'is_enabled' => false // if this is true, the system will do score comparsion against your threshold for the action
7572
]
@@ -83,41 +80,34 @@ For more details please check comments in config file.
8380

8481
#### Display reCAPTCHA v3
8582

83+
Include Google API in header
84+
8685
``` html
87-
{!! app('captcha')->render($$action1,$action2...) !!}
86+
{!! GoogleReCaptchaV3::requireJs() !!}
8887
```
8988

90-
Or use Facade
89+
Include input field
90+
9191
``` html
92-
{!! GoogleReCaptchaV3::render($action1,$action2) !!}
92+
{!! GoogleReCaptchaV3::render('contact_us') !!}
9393
```
9494

9595
Example Usage
9696

9797
``` html
98-
{!! GoogleReCaptchaV3::render($action1,$action2) !!}
98+
{!! GoogleReCaptchaV3::requireJs() !!}
9999

100-
<form method="POST" action="/verify1">
100+
<form method="POST" action="/verify">
101101
@csrf
102-
<input type="hidden" id="your_id_1" name="g-recaptcha-response">
102+
<input type="hidden" id="contactus_id" name="g-recaptcha-response">
103+
{!! GoogleReCaptchaV3::render('contact_us') !!}
104+
103105
<input type="submit" class="g-recaptcha" value="submit">
104106
</form>
105107

106-
<form method="POST" action="/verify2">
107-
@csrf
108-
<input type="hidden" id="your_id_2" name="g-recaptcha-response">
109-
<input type="submit" class="g-recaptcha" value="submit">
110-
</form>
111108
```
112109

113-
- You can pass multiple $action in render(...)function
114-
- Each action should have its own mapped id which you have specified in setting file.
115-
- Please specify your id for the input below:
116-
117-
``` html
118-
<input type="hidden" id="your_id" name="g-recaptcha-response">
119-
```
120-
Note: all values should be registered in googlerecaptchav3 config file in 'setting' section.
110+
Note: all actions should be registered in googlerecaptchav3 config file in 'setting' section.
121111

122112

123113
#### Validation Class (Only support Laravel >= 5.5)
@@ -127,7 +117,7 @@ Note: all values should be registered in googlerecaptchav3 config file in 'setti
127117
``` php
128118
use RyanDeng\GoogleReCaptcha\Validations\GoogleReCaptchaValidationRule
129119
$rule = [
130-
'g-recaptcha-response' => [new GoogleReCaptchaValidationRule('action_name',$ip)]
120+
'g-recaptcha-response' => [new GoogleReCaptchaValidationRule('action_name')]
131121
];
132122
```
133123

@@ -136,14 +126,11 @@ Note: all values should be registered in googlerecaptchav3 config file in 'setti
136126
GoogleReCaptchaValidationRule($actionName, $ip) which accepts two optional parameters:
137127
- $actionName: if its NULL, the package won't verify action with google response.
138128

139-
- $ip: request remote ip, this is Google reCAPTCHA parameter.
140-
141-
142129
#### Facade Class
143130

144131

145132
``` php
146-
GoogleReCaptchaV3::setAction($action)->verifyResponse($response, $ip);
133+
GoogleReCaptchaV3::setAction($action)->verifyResponse($response);
147134
```
148135

149136
$action: Google reCAPTCHA definition
@@ -173,7 +160,7 @@ Remember to register your implementation, e.g.
173160

174161
#### Custom implementation on Request method
175162

176-
The package uses Curl to verify, if you want to use your own request method, You can create your own class and implement
163+
The package uses Guzzle\Http to verify, if you want to use your own request method, You can create your own class and implement
177164
```
178165
RyanDeng\GoogleReCaptcha\Interfaces\RequestClientInterface
179166
```
@@ -186,9 +173,6 @@ Remember to register your implementation.
186173
);
187174
```
188175

189-
## Limitations
190-
One action can only map to one input field id, so you cannot declare multiple id to the same action.
191-
192176
## Security
193177

194178
If you discover any security related issues, please email ryandadeng@gmail.com instead of using the issue tracker.

src/GoogleReCaptchaV3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function render($action, $name = 'g-recaptcha-response')
4747
return app('view')->make($view, $data);
4848
}
4949

50-
public function init()
50+
public function requireJs()
5151
{
5252
return app('view')->make(
5353
$this->defaultHeaderView,

src/Validations/GoogleReCaptchaValidationRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class GoogleReCaptchaValidationRule implements ImplicitRule
1818
protected $ip;
1919
protected $message;
2020

21-
public function __construct($action = null, $ip = null)
21+
public function __construct($action = null)
2222
{
2323
$this->action = $action;
2424
}
@@ -30,7 +30,7 @@ public function __construct($action = null, $ip = null)
3030
*/
3131
public function passes($attribute, $value)
3232
{
33-
$response = GoogleReCaptchaV3::setAction($this->action)->verifyResponse($value, $this->ip);
33+
$response = GoogleReCaptchaV3::setAction($this->action)->verifyResponse($value);
3434
$this->message = $response->getMessage();
3535
return $response->isSuccess();
3636
}

0 commit comments

Comments
 (0)