Add error messages to logs and update the user.

@param Entity\Users $userEntity

@return false
352537
protected function loginFailed(Entity\Users $userEntity)
    {
        $this->flashLogger->error(Trans::__('general.phrase.error-user-name-password-incorrect'));
        $this->systemLogger->info("Failed login attempt for '" . $userEntity->getDisplayname() . "'.", ['event' => 'authentication']);

        // Update the failed login attempts, and perhaps throttle the logins.
        $userEntity->setFailedlogins($userEntity->getFailedlogins() + 1);
        $userEntity->setThrottleduntil($this->throttleUntil($userEntity->getFailedlogins() + 1));
        $userEntity->setPassword(null);
        $this->getRepositoryUsers()->save($userEntity);

        return false;
    }
464456
public function isEntityLocked(User $user, LockableEntityInterface $entity)
    {
        /** @var LockableEntity $lockable */
        $lockable = $this->getLockableEntity($entity);

        if ($this->lockEnabled) {
            $this->removeExpiredLocks($lockable);
            $locks = $this->getEntityVersionLocksByLockableEntity($lockable, $user);

            if ($locks === null || !count($locks)) {
                $this->createEntityVersionLock($user, $lockable);

                $lockable->setUpdated(new \DateTime());
                $this->objectManager->flush();

                return false;
            }

            return true;
        }

        return false;
    }
826130
public function handleLogin(UserEntity $user)
    {
        $accessToken = new AccessToken($this->tokenStorage, $this->tokenStorage);
        $token = $accessToken->createAccessToken('', $user->getId(), null, true);

        return $token;
    }
791136
public static function create(UserEntity $user, Package\Version $packageVersion, $notifyUpdates)
    {
        $result = new static();
        $result->user = $user;
        $result->packageVersion = $packageVersion;
        $result->notifyUpdates = $notifyUpdates ? true : false;

        return $result;
    }
332025
public Response updateUser(UserEntity userEntity) {
		return restClient.put("users/" + userEntity.getUsername(), userEntity, new HashMap<String, String>());
	}
1052277
public function doAuthentication(UserInterface $user)
    {
        /** @var \PServerCore\Entity\Repository\User $repository */
        $repository = $this->entityManager->getRepository($this->getUserEntityClassName());

        // fix if we have a proxy we don´t have a valid entity, so we have to clear before we can create a new select
        $username = $user->getUsername();
        $repository->clear();

        $userNew = $repository->getUser4UserName($username);

        $authService = $this->getAuthService();

        $authService->getStorage()->write($userNew);
    }
543234
public function read(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-read');
    }
175993
public function addUserTypeEntityIfNotExists($entityId, $fieldName, $fields) {
        $item = $this->getUserTypeEntity($entityId, $fieldName);
        if ($item) {
            return $item['ID'];
        }

        return $this->addUserTypeEntity($entityId, $fieldName, $fields);
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
1156274
private function validate(Entity\Users $userEntity)
    {
        $options = [
            'allow_extra_fields' => true,
            'csrf_protection'    => false,
        ];

        /** @var FormInterface $form */
        $form = $this->app['form.factory']->createBuilder(FormType\UserNewType::class, $userEntity, $options)
            ->getForm()
            ->submit($userEntity->toArray())
        ;
        $errors = $form->getErrors(true);
        if ($errors->count() === 0) {
            return null;
        }

        $messages = [];
        foreach ($errors as $error) {
            $messages[] = $error->getMessage();
        }

        return $messages;
    }
252014
public function set($entity, $entity_id, $created, $user_id = null)
    {
        if (!isset($user_id)) {
            $user_id = $this->user->getId(); // Current user
        }

        if ($this->exists($entity, $entity_id, $user_id)) {
            return true;
        }

        if ((GC_TIME - $created) >= $this->getLifespan()) {
            return true; // Expired and was removed
        }

        $data = array(
            'entity' => $entity,
            'user_id' => $user_id,
            'entity_id' => $entity_id
        );

        return $this->add($data);
    }
1303484
private function updateUsers(EntityManager $em)
    {
        $em->getConnection()->executeUpdate(
            'INSERT INTO Users
            (
                id,                     activity,               address,                admin,
                can_change_ftp_profil,  can_change_profil,      city,                   company,
                country,                email,                  fax,                    first_name,
                geoname_id,             guest,                  job,                    last_connection,
                last_name,              ldap_created,           locale,                 login,
                mail_locked,            last_model,             mail_notifications,     nonce,
                password,               push_list,              request_notifications,  salted_password,
                gender,                 phone,                  timezone,               zip_code,
                created,                updated,                deleted
            )
            (
                SELECT
                usr_id,                 activite,               adresse,                create_db,
                canchgftpprofil,        canchgprofil,           ville,                  societe,
                pays,                   usr_mail,               fax,                    usr_prenom,
                geonameid,              invite,                 fonction,               last_conn,
                usr_nom,                ldap_created,           locale,                 usr_login,
                mail_locked,            NULL AS lastModel,      mail_notifications,     '.($this->hasField($em, 'nonce') ? 'nonce' : 'NULL AS nonce').',
                usr_password,           push_list,              request_notifications,  '.($this->hasField($em, 'salted_password') ? 'salted_password' : '0 AS salted_password').',
                usr_sexe,               tel,                    timezone,               cpostal,
                usr_creationdate,       usr_modificationdate,   0
                FROM usr
            )'
        );

        $em->getConnection()->executeUpdate('UPDATE Users SET geoname_id=NULL WHERE geoname_id=0');
        $em->getConnection()->executeUpdate(
            'UPDATE Users SET locale=NULL WHERE locale NOT IN (:locales)',
            ['locales' => array_keys(Application::getAvailableLanguages())],
            ['locales' => Connection::PARAM_STR_ARRAY]
        );
        $em->getConnection()->executeUpdate('UPDATE Users SET deleted=1, login=SUBSTRING(login, 11) WHERE login LIKE "(#deleted_%"');
    }
452850
public function getUser($userId)
    {
        // Check if we've already retrieved this user.
        if (isset($this->userEntities[$userId])) {
            return $this->userEntities[$userId];
        }

        $query = $this->getUserQuery($userId);
        /** @var Entity\Users $userEntity */
        if ($userEntity = $this->findOneWith($query)) {
            $this->unsetSensitiveFields($userEntity);
        }

        // Remember the user
        $this->userEntities[$userId] = $userEntity;

        return $userEntity;
    }
1343810
public function removeByUserId($userId): void
    {
        $results = $this->findBy(['userId' => $userId]);

        foreach ($results as $result) {
            $this->getEntityManager()->remove($result);
        }

        $this->getEntityManager()->flush();
    }
558079
private function createEditForm(UserGroup $entity) {
        $form = $this->createForm(new UserGroupType(), $entity, array(
            'action' => $this->generateUrl('admin_usergroup_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
70503
public function UpdateUser($UserID) {
      // Retrieve a draft count
      $CountDrafts = $this->GetCount($UserID);
      
      // Update CountDrafts column of user table fot this user
      Gdn::UserModel()->SetField($UserID, 'CountDrafts', $CountDrafts);
   }
1142129
public function update($userId, array $data=null)
    {
        $payload = [];
        if( $data !== null ){
            $payload['data'] = $data;
        }
        $response = $this->doRequest('PUT', 'user/' . $userId . '/', $payload);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }