| Conditions | 4 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function verify(Otp $otp): OtpVerificationResult |
||
| 23 | { |
||
| 24 | try { |
||
| 25 | $result = $this->service->verify($otp); |
||
| 26 | } catch (UntrustedSignatureException $e) { |
||
| 27 | $this->logger->alert(sprintf('Yubico responded with invalid signature (%s)', $e->getMessage()), [ |
||
| 28 | 'exception' => $e, |
||
| 29 | 'otp' => $otp->otp, |
||
| 30 | ]); |
||
| 31 | |||
| 32 | return new OtpVerificationResult(OtpVerificationResult::ERROR_BAD_SIGNATURE); |
||
| 33 | } catch (RequestResponseMismatchException $e) { |
||
| 34 | $this->logger->alert(sprintf('Yubico request and response didn\'t match (%s)', $e->getMessage()), [ |
||
| 35 | 'exception' => $e, |
||
| 36 | 'otp' => $otp->otp, |
||
| 37 | ]); |
||
| 38 | |||
| 39 | return new OtpVerificationResult(OtpVerificationResult::ERROR_BACKEND_ERROR); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($result->isSuccessful()) { |
||
| 43 | return $result; |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->logger->critical(sprintf('Yubico responded with error status \'%s\'', $result->getError()), [ |
||
| 47 | 'otp' => $otp->otp, |
||
| 48 | ]); |
||
| 49 | |||
| 50 | return $result; |
||
| 51 | } |
||
| 53 |