Conditions | 8 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function passes($attribute, $response) |
||
17 | { |
||
18 | if (! config('simple-recaptcha-v3.active')) { |
||
19 | return true; |
||
20 | } |
||
21 | |||
22 | $this->userResponse = $response; |
||
23 | |||
24 | if ($this->userResponse === null) { |
||
25 | return false; |
||
26 | } |
||
27 | |||
28 | $this->serviceResponse = $this->getResponse(new CaptchaService()); |
||
29 | |||
30 | if (! empty($this->serviceResponse['error-codes'])) { |
||
31 | return false; |
||
32 | } |
||
33 | |||
34 | if (config('simple-recaptcha-v3.hostname_check') && request()->getHttpHost() !== $this->serviceResponse['hostname']) { |
||
35 | return false; |
||
36 | } |
||
37 | |||
38 | if (! $this->serviceResponse['success'] || $this->serviceResponse['score'] < config('simple-recaptcha-v3.minimum_score')) { |
||
39 | return false; |
||
40 | } |
||
41 | |||
42 | return true; |
||
43 | } |
||
62 |