| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 3 | public function login( |
|
| 35 | string $username, |
||
| 36 | string $password |
||
| 37 | ): ?SessionInterface { |
||
| 38 | 3 | $user = $this->userRepository->findOneBy([ |
|
| 39 | 3 | 'name' => $username, |
|
| 40 | ]); |
||
| 41 | |||
| 42 | 3 | if ($user === null) { |
|
| 43 | 1 | return null; |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | if (password_verify($password, $user->getPassword()) === false) { |
|
| 47 | 1 | return null; |
|
| 48 | } |
||
| 49 | |||
| 50 | 1 | $session = $this->sessionRepository |
|
| 51 | 1 | ->prototype() |
|
| 52 | 1 | ->setActive(true) |
|
| 53 | 1 | ->setUser($user); |
|
| 54 | |||
| 55 | 1 | $this->sessionRepository->save($session); |
|
| 56 | |||
| 57 | 1 | return $session; |
|
| 58 | } |
||
| 60 |