@param User $user

@return bool
541110
private function isSecureExpired(User $user)
    {
        // never expired
        if (!$this->expirationPeriod) {
            return false;
        }

        if (!$lastLogin = $user->getLineLastLogin()) {
            return true;
        }

        return (new \DateTime('-'.$this->expirationPeriod)) > $lastLogin;
    }
166274
public function delete($user)
    {
        if (!is_object($user)) {
            $user = $this->find($user);
        }

        if ($user instanceof User) {
            if ($this->fireEvent('deleting', array($user)) === false) {
                return false;
            }

            $user->delete($this);

            $this->fireEvent('deleted', array($user));
        }
    }
1362878
private function checkActivatedStatus(User $user)
    {
        if (!$user->isActivated()) {
            throw new DisabledException(sprintf('Account `%s`is disabled.', $user->getUsername()));
        }

        return $user;
    }
1165106
public function save(User $user) : bool
    {
        if (!$user->save()) {
            throw new \RuntimeException($this->i18n->t('setrun/user', 'Saving error'));
        }
        return true;
    }
706564
public function delete_user(string $user): bool
	{
		if ( bbn\str::check_name($user) ){
			$this->db->raw_query("
			REVOKE ALL PRIVILEGES ON *.*
			FROM $user");
			return (bool)$this->db->query("DROP USER $user");
		}
		return false;
	}
637496
public function deactivateUser(User $user)
    {
        /** @var Account $account */
        foreach ($user->getAccounts() as $account) {
            $account->setExpirationDate($this->now);
            $this->accountRepository->update($account);
        }
        $this->emitUserDeactivated($user);
    }
261204
public function isVisibleTo(User $user)
    {
        return (bool) $this->newQuery()->whereVisibleTo($user)->find($this->id);
    }
733558
public function update(User $user)
    {
        $url = 'users/' . $user->getAppuserid();

        return $this->updateObject($url, $user);
    }
590359
private function userAttemptBruteForceLock(User $user)
    {
        if ($this->userAttemptBruteForceLockHasExceeded($user)) {
            return true;
        }
        
        $this->attempts = $user->login_attempt + 1;
        
        if ($this->attempts >= $this->allowedAttempts) {
            $user->updateAttributes(['login_attempt_lock_expiration' => time() + $this->lockoutTime]);
        }
        
        $user->updateAttributes(['login_attempt' => $this->attempts]);
    }
790997
public function userHasAccess(User $user)
    {
        if ($this->getWhitelisted() === false) {
            return true;
        }

        $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('user', $user))
                ->setMaxResults(1);

        $serverUsers = $this->users->matching($criteria);
        if ($serverUsers->count() === 0) {
            return false;
        }

        $serverUser = $serverUsers->first();

        if ($serverUser->getBanned() === true) {
            return false;
        }

        if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) {
            return false;
        }

        return true;
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
63717
public function loadUser($user)
    {

        $ok = false;
        if (!empty($user->getRecordId())) {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (user_pk = %d)',
            $user->getRecordId());
        } else {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)',
                           $user->getResourceLink()->getRecordId(),
                           DataConnector::quoted($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY)));
        }
        $rsUser = mysql_query($sql);
        if ($rsUser) {
            $row = mysql_fetch_object($rsUser);
            if ($row) {
                $user->setRecordId(intval($row->user_pk));
                $user->setResourceLinkId(intval($row->resource_link_pk));
                $user->ltiUserId = $row->lti_user_id;
                $user->ltiResultSourcedId = $row->lti_result_sourcedid;
                $user->created = strtotime($row->created);
                $user->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }
202650
public function isBuyer(User $user)
    {
        return (bool) $this->purchases()->whereHas('buyer', function ($query) use ($user) {
            return $query->where('user_id', $user->userId);
        })->count();
    }
117271
public function bindUser(User $user, $binding)
    {
        return $this->bindUserID(intval($user->getUserID(), 10), $binding);
    }
1102391
public static function forUser(User $user)
    {
        if ($user->getIsGuest()) {
            return Yii::$app->session;
        }

        return Yii::createObject(['class' => RemoteCartStorage::class, 'sessionCartId' => 'yz\shoppingcart\ShoppingCart']);
    }
342999
public function deleteUser($user)
    {

        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
               'WHERE (user_pk = :id)';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $user->getRecordId(), PDO::PARAM_INT);
        $ok = $query->execute();

        if ($ok) {
            $user->initialize();
        }

        return $ok;

    }
771261
public function login(User $user, $password)
    {
        if ($user->isPasswordValid($password)) {
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->tokenStorage->setToken($token);
            $user->setLastLogin(new \DateTime());
            $this->save($user);

            return true;
        }

        return false;
    }