| Conditions | 5 |
| Paths | 11 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 19 | public function verify($userId, $yubiKeyOtp, $yubiKeyId = null) |
||
|
|
|||
| 20 | { |
||
| 21 | try { |
||
| 22 | $validator = new Validator(new CurlMultiHttpClient()); |
||
| 23 | $response = $validator->verify($yubiKeyOtp); |
||
| 24 | |||
| 25 | if ($response->success()) { |
||
| 26 | if (!is_null($yubiKeyId)) { |
||
| 27 | // the yubiKeyId MUST match the Id from the validation |
||
| 28 | // response |
||
| 29 | if ($yubiKeyId !== $response->id()) { |
||
| 30 | throw new YubiKeyException('user not bound to this YubiKey ID'); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $response->id(); |
||
| 35 | } |
||
| 36 | |||
| 37 | throw new YubiKeyException(sprintf('YubiKey OTP is not valid: %s', $response->status())); |
||
| 38 | } catch (YubiTweeException $e) { |
||
| 39 | throw new YubiKeyException(sprintf('YubiKey OTP validation failed: %s', $e->getMessage())); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.