Ejemplo n.º 1
0
 private function ajaxItemEdit(Location $loc, $message, $value)
 {
     $result = AjaxController::itemEdit($this->get('validator'), $this->get('translator'), $this->get('doctrine'), $loc, $message, $value);
     $this->user_reconnect();
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @Route("/ajax/changepassword", name="_account_ajax_changepassword")
  */
 public function ajaxChangePassword(Request $request)
 {
     $data = json_decode($request->getContent());
     $translator = $this->get('translator');
     $validator = $this->get('validator');
     $cp = new ChangePassword();
     $cp->setOldPassword(@$data->old_password);
     $cp->setNewPassword(@$data->new_password);
     $cp->setConfirmPassword(@$data->confirm_password);
     $errors = $validator->validate($cp);
     if (count($errors) > 0) {
         $result = array('flash' => array('title' => $translator->trans('Error'), 'message' => $translator->trans($errors[0]->getMessage()), 'type' => 'error'));
         return AjaxController::jsonResponse(false, $result);
     }
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $this->get('user_manager')->setPassword($data->new_password, $user, false);
     return AjaxController::itemEdit($validator, $translator, $this->get('doctrine'), $user, 'Password has been changed!', '');
 }