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