| Conditions | 6 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function getAuthenticatedUser(string $email, string $password): UserInterface |
||
| 29 | { |
||
| 30 | $email = trim($email); |
||
| 31 | $password = trim($password); |
||
| 32 | |||
| 33 | if ($email === '' || $password === '') { |
||
| 34 | throw new MissingCredentialException('Missing or empty credentials'); |
||
| 35 | } |
||
| 36 | |||
| 37 | try { |
||
| 38 | $user = $this->userProvider->getUserByEmail($email); |
||
| 39 | if ($user !== null) { |
||
| 40 | $dbPassword = $user->getDetail('password'); |
||
| 41 | if ($dbPassword === $password) { |
||
| 42 | return $user; |
||
| 43 | } |
||
| 44 | throw new BadCredentialException('Login / password does not match'); |
||
| 45 | } |
||
| 46 | } catch (\Throwable $e) { |
||
| 47 | throw new AuthException($e->getMessage()); |
||
| 48 | } |
||
| 49 | |||
| 50 | throw new AuthException('Unknown authentication exception'); |
||
| 51 | } |
||
| 53 |