Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. public function patchUserPasswordAction(ParamFetcherInterface $fetcher)
  2.     {
  3.         try {
  4.             $user = $this->getUser();
  5.             $encoder = $this->get('security.password_encoder');
  6.            
  7.             $newPassword = $fetcher->get('newPassword');
  8.             $confirmNewPassword = $fetcher->get('confirmNewPassword');
  9.  
  10.             if ($newPassword !== $confirmNewPassword) {
  11.                 throw new BadRequestHttpException('Пароли не совпадают');
  12.             }
  13.  
  14.             $this->get('app.service.user_provider')->updatePassword($user, $encoder->encodePassword($user, $fetcher->get('newPassword')));
  15.  
  16.             return new JsonResponse(
  17.                 [
  18.                     'ok' => 200,
  19.                 ]
  20.             );
  21.  
  22.  
  23.         } catch (\Exception $e) {
  24.             throw new BadRequestHttpException($e->getMessage(), $e);
  25.         }
  26.  
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement