Conditions | 6 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
42 | public function validate($token, Constraint $constraint) |
||
43 | { |
||
44 | if (isset($token['coinhive-captcha-token']) && $token['coinhive-captcha-token']) { |
||
45 | $res = $this->client |
||
46 | ->request( |
||
47 | 'POST', |
||
48 | 'https://api.coinhive.com/token/verify', |
||
49 | [ |
||
50 | 'headers' => [ |
||
51 | 'hashes' => 256, |
||
52 | 'secret' => $this->siteKey, |
||
53 | 'token' => $token['coinhive-captcha-token'] |
||
54 | ] |
||
55 | ] |
||
56 | ) |
||
57 | ->getBody() |
||
58 | ->getContents() |
||
59 | ; |
||
60 | |||
61 | $res = json_decode($res, true); |
||
62 | |||
63 | if ($res && isset($res['success']) && $res['success']) { |
||
64 | return false; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | return $this->context->addViolation($constraint->message); |
||
69 | } |
||
71 |