Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
23 | public function postUserPassword(ChangePasswordRequest $request, User $user, UserPasswordEncoderInterface $passwordEncoder) |
||
24 | { |
||
25 | $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); |
||
26 | |||
27 | if ($user->getId() !== $this->getUser()->getId()) { |
||
28 | throw new AccessDeniedHttpException(); |
||
29 | } |
||
30 | |||
31 | if ($user->isPasswordValid($request->get('old_password'), $passwordEncoder) === false) { |
||
32 | throw new BadRequestHttpException(); |
||
33 | } |
||
34 | |||
35 | $user->setPlainPassword($request->get('new_password')); |
||
36 | $this->getDoctrine()->getManager()->flush(); |
||
37 | |||
38 | return new JsonResponse(); |
||
39 | } |
||
40 | } |
||
41 |