Handle user name update.

@author Vova Feldman (@svovaf)
@since  1.0.9
@uses   FS_Api

@return object
553359
private function update_user_name() {
            $this->_logger->entrance();
            $name = fs_request_get( 'fs_user_name_' . $this->get_unique_affix(), '' );

            $api  = $this->get_api_user_scope();
            $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
                'name' => $name,
            ) );

            if ( ! isset( $user->error ) ) {
                $this->_user->first = $user->first;
                $this->_user->last  = $user->last;
                $this->_store_user();
            } else {
                // handle different error cases.

            }

            return $user;
        }
688222
public function changeUsername()
    {
        if ($this->validate()) {
            $username = $this->user->createUsername($this->username);
            if (!$username) {
                return false;
            }
            return $username->save();
        }
        return false;
    }
183345
public function update(LoggedUserNameUpdate $request)
    {
        $user = Auth::user();
        $user->update($request->only('name'));
        return $user;
    }
1140181
public function actionUpdateSelf()
    {
        $model = User::findOne(['id' => yii::$app->getUser()->getIdentity()->getId()]);
        $model->setScenario('self-update');
        if (yii::$app->getRequest()->getIsPost()) {
            if ($model->load(yii::$app->getRequest()->post()) && $model->selfUpdate()) {
                Yii::$app->getSession()->setFlash('success', yii::t('cms', 'Success'));
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0] . '<br>';
                }
                Yii::$app->getSession()->setFlash('error', $err);
            }
            $model = User::findOne(['id' => yii::$app->getUser()->getIdentity()->getId()]);
        }

        return $this->render('update', [
            'model' => $model,
        ]);
    }
603387
public function get_user_name()
    {
        if (is_object($this->user)) {
            return $this->user->get_username();
        }
        else if (isset($_SESSION['username'])) {
            return $_SESSION['username'];
        }
    }
159679
def user_update(self, username, data):
        
        url = 'rest/api/2/user?username={0}'.format(username)
        return self.put(url, data=data)
559577
def update_user(self):
        
        # First create a copy of the current user
        user_dict = self.serialize()
        # Then delete the entities in the description field
        del user_dict['description']['entities']
        # Then upload user_dict
        user, meta = self._api.update_user('me', data=user_dict)
1260714
public function processUpdateAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth(AdminResources::MODULE, Team::getModuleCode(),
                AccessManager::UPDATE)
        ) {
            return $response;
        }

        // Error (Default: false)
        $error_msg = false;

        // Create the Form from the request
        $changeForm = $this->getUpdateForm($this->getRequest());


        $con = Propel::getConnection();
        $con->beginTransaction();

        try {
            // Check the form against constraints violations
            $form = $this->validateForm($changeForm, "POST");

            // Get the form field values
            $data = $form->getData();

            $updatedObject = $this->getService()->updateFromArray($data, $this->getCurrentEditionLocale());

            // Check if object exist
            if (!$updatedObject) {
                throw new \LogicException(
                    $this->getTranslator()->trans("No %obj was updated.", ['%obj' => static::CONTROLLER_ENTITY_NAME])
                );
            }

            $con->commit();
            // If we have to stay on the same page, do not redirect to the successUrl,
            // just redirect to the edit page again.
            if ($this->getRequest()->get('save_mode') == 'stay') {
                return $this->redirectToEditionTemplate($this->getRequest());
            }

            // Redirect to the success URL
            return $this->generateSuccessRedirect($changeForm);

        } catch (FormValidationException $ex) {
            $con->rollBack();
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            $con->rollBack();
            // Any other error
            $error_msg = $ex->getMessage();
        }

        if (false !== $error_msg) {
            // At this point, the form has errors, and should be redisplayed.
            $this->setupFormErrorContext(
                $this->getTranslator()->trans("%obj modification", ['%obj' => static::CONTROLLER_ENTITY_NAME]),
                $error_msg,
                $changeForm,
                $ex
            );

            return $this->getEditRenderTemplate();
        }
    }
176814
public function preUpdate(UpdateEvent $event)
    {
        $oldData = $event->getOldData();
        $user = $event->getObject();

        if (!empty($oldData) && $oldData['username'] !== $user->getUsername()) {
            $userRole = $this->roleManager->getUserRole($oldData['username']);
            $this->roleManager->renameUserRole($userRole, $user->getUsername());
            // TODO : rename personal WS if user is renamed
        }
    }
734808
function update(req, res, next) {
  var body = req.body;
  delete body.username;

  db.users.update(req.params.user, body, function(err, user) {
    if(err) { return next(err); }
    res.json(201, user);
  });
}
811847
public function processUpdateAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
            return $response;
        }

        // Error (Default: false)
        $error_msg = false;

        // Create the Form from the request
        $changeForm = $this->getUpdateForm($this->getRequest());

        try {
            // Check the form against constraints violations
            $form = $this->validateForm($changeForm, "POST");

            // Get the form field values
            $data = $form->getData();

            // Create a new event object with the modified fields
            $changeEvent = $this->getUpdateEvent($data);
            $changeEvent->bindForm($form);

            // Dispatch Update Event
            $this->dispatch($this->updateEventIdentifier, $changeEvent);

            // Check if object exist
            if (! $this->eventContainsObject($changeEvent)) {
                throw new \LogicException(
                    $this->getTranslator()->trans("No %obj was updated.", ['%obj' => $this->objectName])
                );
            }

            // Log object modification
            if (null !== $changedObject = $this->getObjectFromEvent($changeEvent)) {
                $this->adminLogAppend(
                    $this->resourceCode,
                    AccessManager::UPDATE,
                    sprintf(
                        "%s %s (ID %s) modified",
                        ucfirst($this->objectName),
                        $this->getObjectLabel($changedObject),
                        $this->getObjectId($changedObject)
                    ),
                    $this->getObjectId($changedObject)
                );
            }

            // Execute additional Action
            $response = $this->performAdditionalUpdateAction($changeEvent);

            if ($response == null) {
                // If we have to stay on the same page, do not redirect to the successUrl,
                // just redirect to the edit page again.
                if ($this->getRequest()->get('save_mode') == 'stay') {
                    return $this->redirectToEditionTemplate($this->getRequest());
                }

                // Redirect to the success URL
                return $this->generateSuccessRedirect($changeForm);
            } else {
                return $response;
            }
        } catch (FormValidationException $ex) {
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            // Any other error
            $error_msg = $ex->getMessage();
        }

        if (false !== $error_msg) {
            // At this point, the form has errors, and should be redisplayed.
            $this->setupFormErrorContext(
                $this->getTranslator()->trans("%obj modification", ['%obj' => $this->objectName]),
                $error_msg,
                $changeForm,
                $ex
            );

            return $this->renderEditionTemplate();
        }
    }
826672
public function updateAction()
    {
        $this->checkAuth($this->resources, $this->modules, AccessManager::UPDATE);

        $baseForm = $this->getUpdateForm();

        $baseForm->getFormBuilder()
            ->addEventListener(
                FormEvents::PRE_SUBMIT,
                [$this, "hydrateUpdateForm"]
            )
        ;

        $con = Propel::getConnection();
        $con->beginTransaction();

        try {
            $form = $this->validateForm($baseForm);
            $data = $form->getData();
            $event = $this->getUpdateEvent($data);

            $dispatcher = $this->getDispatcher();
            foreach ($this->updateEvents as $eventName) {
                $dispatcher->dispatch($eventName, $event);
            }

            $this->afterUpdateEvents($event, $data);

            $con->commit();
        } catch (HttpException $e) {
            $con->rollBack();

            return new JsonResponse(["error" => $e->getMessage()], $e->getStatusCode());
        } catch (\Exception $e) {
            $con->rollBack();

            return new JsonResponse(["error" => $e->getMessage()], 500);
        }

        $obj = $this->extractObjectFromEvent($event);
        $id = $this->extractIdFromObject($obj);

        return new JsonResponse(
            $this->getLoopResults(
                array_merge(
                    $this->getRequest()->query->all(),
                    [$this->idParameterName => $id]
                )
            ),
            201
        );
    }
437243
public function handleGetUpdates(): self
    {
        $get_updates_response = $this->telegram->handleGetUpdates();

        // Check if the user has set a custom callback for handling the response.
        if ($this->custom_get_updates_callback !== null) {
            $this->handleOutput(\call_user_func($this->custom_get_updates_callback, $get_updates_response));
        } else {
            $this->handleOutput($this->defaultGetUpdatesCallback($get_updates_response));
        }

        return $this;
    }
596828
protected function update() {
		
		if(!is_null($this->callback)) {
			
			// Not using application/javascript for compatibility reasons with older browsers.
			$this->headers->set('Content-Type', 'text/javascript');
				
			return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); 

		}
		
		// set header only when there is none or when it equals 'text/javascript' (from a previous update with callback)
		// in order to not overwrite a custom definition

		if(!$this->headers->has('Content-Type') || $this->headers->get('Content-Type') === 'text/javascript') {
			$this->headers->set('Content-Type', 'application/json');
		}

		return $this->setContent($this->data);

	}
1281021
public function update()
        {
                $ok = true;

                // perform updates...
                $ok = $this->updateFile(self::FILENAME_RULES);

                if ($ok)
                        $ok = $this->updateFile(self::FILENAME_CONVERTER);

                return $ok;
        }
1042900
function update(form) {
      // refuse to work with invalid data
      if (!vm.user._id || form && !form.$valid) {
        return;
      }

      UserService.update(vm.user)
        .then(updateUserSuccess)
        .catch(updateUserCatch);

      function updateUserSuccess(updatedUser) {
        // update the display name after successful save
        vm.displayName = updatedUser.name;
        Toast.show({text: 'User ' + updatedUser.name + ' updated'});
        if (form) {
          form.$setPristine();
        }
      }

      function updateUserCatch(err) {
        Toast.show({
          type: 'warn',
          text: 'Error while updating user ' + vm.displayName,
          link: {state: $state.$current, params: $stateParams}
        });

        if (form && err) {
          form.setResponseErrors(err.data);
        }
      }
    }
270938
public function update_token($username) {
        $token = self::hash();

        $query = sprintf(self::UPDATE_VALUE,
            $this->params['table'],
            $this->params['token'],
            $this->pdo->quote($token),
            $this->params['username'],
            $this->pdo->quote($username));

        $stmt = $this->pdo->query($query);

        if($stmt === FALSE || $stmt->rowCount() !== 1) {
            throw new UserException('Token not found');
        }

        return $token;
    }