| Conditions | 3 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function __invoke(Request $request) |
||
| 26 | { |
||
| 27 | $data = $this->serializer->decode($request->getContent(), $this->getFormat($request), []); |
||
| 28 | |||
| 29 | $username = $data['username']; |
||
| 30 | $token = $data['token']; |
||
| 31 | $user = $this->userRepository->findOneByPasswordResetToken( |
||
| 32 | $username, |
||
| 33 | $token |
||
| 34 | ); |
||
| 35 | if (!$user) { |
||
| 36 | return $this->getResponse($request, null, Response::HTTP_NOT_FOUND); |
||
| 37 | } |
||
| 38 | |||
| 39 | try { |
||
| 40 | $this->passwordManager->passwordReset($user, $data['password']); |
||
| 41 | |||
| 42 | return $this->getResponse($request); |
||
| 43 | } catch (AuthenticationException $exception) { |
||
| 44 | $errors = $exception->getMessageData(); |
||
| 45 | |||
| 46 | return $this->getResponse($request, $errors, Response::HTTP_BAD_REQUEST); |
||
| 47 | } |
||
| 50 |