code: public function updatePasswordAction(Request $request)
      {
          $user = $this->getUser();
          $form = $this->createForm(ChangePasswordType::class);
  
          $form->bind($request);
          $data = $form->getData();
  
          /** @var $factory \Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface */
          $factory = $this->get('security.encoder_factory');
          $encoder = $factory->getEncoder($user);
          $current = $encoder->encodePassword($data['current'], $user->getSalt());
  
          if ($current !== $user->getPassword()) {
              $form->get('current')->addError(new FormError('Current password is not correct'));
          }
  
          if ($form->isValid()) {
              $user->setPassword($encoder->encodePassword($data['password'], $user->getSalt()));
  
              $em = $this->getDoctrine()->getManager();
              $em->persist($user);
              $em->flush();
  
              $this->get('session')->getFlashBag()->set('success', 'Your password has been changed.');
  
              return new JsonReloadResponse();
          }
  
          return new JsonErrorResponse($form);
      }
docs: Updates the current user's password
  
  @Route("/password/update", name="orkestra_profile_password_update", defaults={"_format"="json"})
  @Secure(roles="ROLE_USER")
  @Method("POST")