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