File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ add this to your components main.php
31
31
32
32
``` php
33
33
'components' => [
34
- ...
35
- 'reCaptcha3' => [
36
- 'class' => 'kekaadrenalin\recaptcha3\ReCaptcha',
37
- 'site_key' => 'site_key_###',
38
- 'secret_key' => 'secret_key_###',
39
- ],
34
+ ...
35
+ 'reCaptcha3' => [
36
+ 'class' => 'kekaadrenalin\recaptcha3\ReCaptcha',
37
+ 'site_key' => 'site_key_###',
38
+ 'secret_key' => 'secret_key_###',
39
+ ],
40
40
41
41
```
42
42
@@ -57,7 +57,13 @@ public function rules()
57
57
```
58
58
59
59
``` php
60
- <?= $form->field($model, 'reCaptcha')->widget(\kekaadrenalin\recaptcha3\ReCaptchaWidget::class) ?>
60
+ <?= $form->field($model, 'reCaptcha')->widget(\kekaadrenalin\recaptcha3\ReCaptchaWidget::class) ?>
61
61
```
62
62
63
+ For tests
64
+ ---------
63
65
66
+ Use key ``` RECAPTCHA_OFF ``` in ``` index-test.php ``` for disable recaptcha's validate:
67
+ ``` php
68
+ define('RECAPTCHA_OFF', true);
69
+ ```
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class ReCaptcha extends \yii\base\Component
22
22
*/
23
23
public function init ()
24
24
{
25
- parent ::init (); // TODO: Change the autogenerated stub
25
+ parent ::init ();
26
26
27
27
if (empty ($ this ->site_key )) {
28
28
throw new \Exception ('site key cant be null ' );
@@ -31,6 +31,8 @@ public function init()
31
31
if (empty ($ this ->secret_key )) {
32
32
throw new \Exception ('secret key cant be null ' );
33
33
}
34
+
35
+ defined ('RECAPTCHA_OFF ' ) or define ('RECAPTCHA_OFF ' , false );
34
36
}
35
37
36
38
/**
@@ -49,10 +51,13 @@ public function registerScript($view)
49
51
/**
50
52
* @param $value
51
53
*
52
- * @return bool
54
+ * @return bool|int
53
55
*/
54
56
public function validateValue ($ value )
55
57
{
58
+ if (defined ('RECAPTCHA_OFF ' ) && RECAPTCHA_OFF ) {
59
+ return 1 ;
60
+ }
56
61
57
62
try {
58
63
$ response = $ this ->curl ([
@@ -75,7 +80,7 @@ public function validateValue($value)
75
80
*
76
81
* @param array $params
77
82
*
78
- * @return bool
83
+ * @return mixed
79
84
*/
80
85
protected function curl (array $ params )
81
86
{
You can’t perform that action at this time.
0 commit comments