protected function update()
 {
     $missing_fields = UserController::validateJSONFormat($this->body, User::REQUIRED_PUT_FIELDS);
     // Check that required fields are not missing
     if (!$missing_fields) {
         $mapper = new UserDBMapper();
         $json = $this->body;
         $json["id"] = $this->id;
         $user = User::fromJSON($json);
         $db_response = $mapper->update($user);
         if ($db_response instanceof DBError) {
             $response = new ErrorResponse($db_response);
         } else {
             $response = $this->get();
         }
     } else {
         $response = new ErrorResponse(new MalformedJSONFormatError($missing_fields));
     }
     $this->controller = new ErrorController(new AuthenticationError($this->method));
     return $response;
 }