| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.3244 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 1 | public function login(string $login, string $password): IdentityInterface |
|
| 31 | { |
||
| 32 | 1 | $identity = $this->identityRepository->findByLogin($login); |
|
| 33 | 1 | if ($identity === null) { |
|
| 34 | throw new BadRequestException('No such user.'); |
||
| 35 | } |
||
| 36 | |||
| 37 | 1 | if (!$identity->validatePassword($password)) { |
|
| 38 | throw new BadRequestException('Invalid password.'); |
||
| 39 | } |
||
| 40 | |||
| 41 | 1 | if (!$this->currentUser->login($identity)) { |
|
| 42 | throw new BadRequestException(); |
||
| 43 | } |
||
| 44 | |||
| 45 | 1 | $identity->resetToken(); |
|
| 46 | 1 | $this->identityRepository->save($identity); |
|
| 47 | 1 | return $identity; |
|
| 48 | } |
||
| 56 |