@param $user

@throws BunqException
328842
private function setUser($user)
    {
        if ($user instanceof UserPerson) {
            $this->userPerson = $user;
        } elseif ($user instanceof UserCompany) {
            $this->userCompany = $user;
        } elseif ($user instanceof UserApiKey) {
            $this->userApiKey = $user;
        } else {
            throw new BunqException(vsprintf(self::ERROR_UNEXPECTED_USER_INSTANCE, [get_class($user)]));
        }
    }
150826
public function setUser($user)
    {
        $regex = '`^' . self::$_regexUser . '$`i';

        if (preg_match_all($regex, $user, $matches) !== 1) {

            throw new InvalidArgumentException('User must match ' . $regex);
        }

        $this->_user = $user;
    }
298967
public static function fillSession($user) {
    if (!isset(self::$serverTimezone)) {
      self::$serverTimezone = date_default_timezone_get();
    }
    self::$currentUser = $user;
    date_default_timezone_set($user->getTimezone());
    self::$currentUser->updateDataProtection();
  }
746510
public function save(User $user)
    {
        if ($user->getPlainPassword()) {
            $this->setPlainTextPassword($user, $user->getPlainPassword());
        }

        $this->entityManager->persist($user);
        $this->entityManager->flush();

        if ($user->isNew() && !$user->isEmailSent()) {
            try {
                $this->userMailer->sendNewUserMail($user);
                $user->setEmailSent(true);
                $this->entityManager->flush($user);
            } catch (\Exception $e) {
                $this->logger->alert($e->getMessage());
            }
        }
        if ($user->getPasswordRequestedAt() && !$user->isEmailSent()) {
            try {
                $this->userMailer->sendResetPasswordMail($user);
                $user->setEmailSent(true);
                $this->entityManager->flush($user);
            } catch (\Exception $e) {
                $this->logger->alert($e->getMessage());
            }
        }
    }
233292
public function setUser(User $user): void
    {
        $this->user = $user;
        $this->user->setAcl($this);

        $userRole = $this->user->getRole();
        if ($userRole != null && !empty($this->rules)) {
            foreach ($this->rules as $role => $rules) {
                if ($userRole == $role) {
                    foreach ($rules as $uri => $rules) {
                        $this->user->setPermissionsOf($uri, (array) explode(',', $rules) /* 'read,write' etc. */);
                    }
                    break;
                }
            }
        }
    }
1077062
public function grantTo($user): void
    {
        $userModel = config('auth.providers.users.model');

        if (is_int($user) && !$userModel::find($user)) {
            return;
        }

        $this->users()->attach($user);
    }
1314473
private function userAttemptBruteForceLockHasExceeded(User $user)
    {
        if ($user->login_attempt_lock_expiration > time()) {
            $user->updateAttributes(['login_attempt' => 0]);
            
            return true;
        }
        
        return false;
    }
441344
public function updateAccount(User $user)
    {
        if ($this->client === null) {
            throw new LogicException("Client property must be set before update an account");
        }

        if (null === $account = $this->app['repo.api-accounts']->findByUserAndApplication($user, $this->client)) {
            $account = $this->app['manipulator.api-account']->create($this->client, $user, $this->getVariable('api_version', V2::VERSION));
        }

        return $account;
    }
132304
protected function createRememberTokenIfDoesntExist(UserContract $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
1088606
protected function checkActivation(UserInterface $user)
    {
        $completed = $this->activations->completed($user);

        if (! $completed) {
            $exception = new NotActivatedException('Your account has not been activated yet.');

            $exception->setUser($user);

            throw $exception;
        }
    }
1048227
protected function setCurrentUser($user) {
		
		if (is_a($user,'Pair\User')) {

			$this->currentUser = $user;
			
			// sets user language
			$tran = Translator::getInstance();
			$tran->setLocale($user->getLocale());
				
		}

	}
780221
protected function createEntityVersionLock(User $user, LockableEntity $entity)
    {
        /** @var EntityVersionLock $lock */
        $lock = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock')->findOneBy([
            'owner' => $user->getUsername(),
            'lockableEntity' => $entity,
        ]);
        if (!$lock) {
            $lock = new EntityVersionLock();
        }
        $lock->setOwner($user->getUsername());
        $lock->setLockableEntity($entity);
        $lock->setCreatedAt(new \DateTime());
        $this->objectManager->persist($lock);
        $this->objectManager->flush();
    }
639055
private function cleanAuthProvider(User $user)
    {
        $providers = $this->objectManager->getRepository('Phraseanet:UsrAuthProvider')
            ->findBy(['user' => $user]);

        foreach ($providers as $provider) {
            $this->objectManager->remove($provider);
        }
    }
379711
public function push($user)
    {
        if (! isset($this->data['message'])) {
            throw new Exception('You must supply a message');
        }

        // Fields to send
        $data = array_merge(
            $this->data,
            array(
                'user' => $user,
            )
        );

        // Send data to API
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $this->api_url);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $result = json_decode(curl_exec($curl), true);
        curl_close($curl);

        return isset($result['status']) && (int) $result['status'] === 1;
    }
618899
public static function actingAs($user, $scopes = [])
    {
        $token = Mockery::mock(Token::class)->shouldIgnoreMissing(false);

        foreach ($scopes as $scope) {
            $token->shouldReceive('can')->with($scope)->andReturn(true);
        }

        $uses = array_flip(class_uses_recursive($user));

        if (! isset($uses[HasApiTokens::class])) {
            throw new Exception('The model ['.get_class($user).'] must uses the trait '.HasApiTokens::class);
        }

        $user->withAccessToken($token);

        $guard = AuthConfigHelper::getUserGuard($user);

        app('auth')->guard($guard)->setUser($user);

        app('auth')->shouldUse($guard);
    }
458023
public function loadUser($user)
    {

        $now = time();
        $user->created = $now;
        $user->updated = $now;

        return true;

    }
286375
public function updateUser(User $user)
    {
        $this->find("id", $user->id);
        $this->setUserData($user);
        $this->save();
    }