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
3131
3232``` php
3333'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+ ],
4040
4141```
4242
@@ -57,7 +57,13 @@ public function rules()
5757```
5858
5959``` php
60- <?= $form->field($model, 'reCaptcha')->widget(\kekaadrenalin\recaptcha3\ReCaptchaWidget::class) ?>
60+ <?= $form->field($model, 'reCaptcha')->widget(\kekaadrenalin\recaptcha3\ReCaptchaWidget::class) ?>
6161```
6262
63+ For tests
64+ ---------
6365
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
2222 */
2323 public function init ()
2424 {
25- parent ::init (); // TODO: Change the autogenerated stub
25+ parent ::init ();
2626
2727 if (empty ($ this ->site_key )) {
2828 throw new \Exception ('site key cant be null ' );
@@ -31,6 +31,8 @@ public function init()
3131 if (empty ($ this ->secret_key )) {
3232 throw new \Exception ('secret key cant be null ' );
3333 }
34+
35+ defined ('RECAPTCHA_OFF ' ) or define ('RECAPTCHA_OFF ' , false );
3436 }
3537
3638 /**
@@ -49,10 +51,13 @@ public function registerScript($view)
4951 /**
5052 * @param $value
5153 *
52- * @return bool
54+ * @return bool|int
5355 */
5456 public function validateValue ($ value )
5557 {
58+ if (defined ('RECAPTCHA_OFF ' ) && RECAPTCHA_OFF ) {
59+ return 1 ;
60+ }
5661
5762 try {
5863 $ response = $ this ->curl ([
@@ -75,7 +80,7 @@ public function validateValue($value)
7580 *
7681 * @param array $params
7782 *
78- * @return bool
83+ * @return mixed
7984 */
8085 protected function curl (array $ params )
8186 {
You can’t perform that action at this time.
0 commit comments