Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function patchUserPasswordAction(ParamFetcherInterface $fetcher)
- {
- try {
- $user = $this->getUser();
- $encoder = $this->get('security.password_encoder');
- $newPassword = $fetcher->get('newPassword');
- $confirmNewPassword = $fetcher->get('confirmNewPassword');
- if ($newPassword !== $confirmNewPassword) {
- throw new BadRequestHttpException('Пароли не совпадают');
- }
- $this->get('app.service.user_provider')->updatePassword($user, $encoder->encodePassword($user, $fetcher->get('newPassword')));
- return new JsonResponse(
- [
- 'ok' => 200,
- ]
- );
- } catch (\Exception $e) {
- throw new BadRequestHttpException($e->getMessage(), $e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement