Loads and returns the user throttles collection.

@param  \Cartalyst\Sentinel\Users\UserInterface  $user
@return \Illuminate\Database\Eloquent\Collection
351921
protected function loadUserThrottles(UserInterface $user)
    {
        $interval = Carbon::now()
            ->subSeconds($this->userInterval);

        return $this
            ->createModel()
            ->newQuery()
            ->where('type', 'user')
            ->where('user_id', $user->getUserId())
            ->where('created_at', '>', $interval)
            ->get();
    }
1238953
private function getPermissionTable(User $user) {
		$userId = $user->getId();
		if ($this->permissionTable->has($userId)) {
			return $this->permissionTable->get($userId);
		}

		// always allow what guests can do
		$guestGroup = GroupQuery::create()->findOneByIsGuest(true);

		// collect groups from user
		$groups = GroupQuery::create()->filterByUser($user)->find();
		$userGroup = GroupQuery::create()->filterByOwnerId(($userId))->findOne();
		if ($userGroup) {
			$groups[] = $userGroup;
		}
		$groups[] = $guestGroup;

		// ... structure them
		$permissionTable = new Set();
		foreach ($groups as $group) {
			foreach ($group->getActions() as $action) {
				$permissionTable->add($action->getId());
			}
		}

		$this->permissionTable->set($userId, $permissionTable);

		return $this->permissionTable->get($userId);
	}
29007
protected function processUserGroups(UserInterface $user, $userGroups)
    {
        $get = function($entity) {
            /* @var UserInterface $entity */
            return $entity->getId();
        };

        $delete = function($userGroup) use ($user) {
            $user->removeUserGroup($userGroup);
            $this->em->remove($userGroup);
        };

        $update = function($userGroup, $userGroupData) {
            return $this->updateUserGroup($userGroup, $userGroupData);
        };

        $add = function($userGroup) use ($user) {
            return $this->addUserGroup($user, $userGroup);
        };

        $entities = $user->getUserGroups();

        $result = $this->processSubEntities(
            $entities,
            $userGroups,
            $get,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        return $result;
    }
1072406
public function getCoins(UserInterface $user)
    {
        $coinsEntry = $this->getCoinsEntry($user);
        $coins = 0;
        if ($coinsEntry) {
            $coins = $coinsEntry->getCash();
        }

        return $coins;
    }
1296413
public function addUser(UserInterface $user)
    {
        $this->users->add($user);

        if ($user->hasRole($this) === false)
            $user->addRole($this);

        return $this;
    }
725868
protected function save(UserInterface $user)
    {
        try
        {
            $entityManager = $this->getEntityManager();
            $entityManager->persist($user);
            $entityManager->flush();

            return $user;
        }
        catch (\Exception $e)
        {
            return false;
        }
    }
1095165
public function findUserInbox(UserInterface $user): InboxInterface
    {
        /** @var InboxInterface $inbox */
        if (!$inbox = $this->repository->findOneBy(['user' => $user])) {
            $class = $this->repository->getClassName();
            $inbox = new $class();
            $inbox->setUser($user);
            $this->repository->add($inbox);
        }

        return $inbox;
    }
1037370
public function getUserRole(UserInterface $user)
    {
        $currentRole = '';
        $userRoles = $user->getRoles();

        if (in_array($userRoles[0], $this->getOrderedRoles())) {
            $currentRole = $userRoles[0];
        }

        return $currentRole;
    }
761122
private function serializeRestrictions(User $user)
    {
        return [
            'disabled' => !$user->isEnabled(),
            'removed' => $user->isRemoved(),
            'dates' => DateRangeNormalizer::normalize($user->getInitDate(), $user->getExpirationDate()),
        ];
    }
173934
public function getQuestionnaireStarted(UserInterface $user)
    {
        $userSessions = $this->manager->getRepository('QcmPublicBundle:UserSession')->findBy(array(
            'user' => $user
        ));

        foreach ($userSessions as $userSession) {
            $configuration = $userSession->getConfiguration();
            if (!is_null($configuration->getStartAt()) && is_null($configuration->getEndAt())) {
                $this->startQuestionnaire($userSession);
                $this->getLastAnsweredQuestion();
                break;
            }
        }
    }
1093582
public function create(UserInterface $user) {
    $this->tokens->purge($user);
    return $this->tokens->create($user);
  }
1048807
public function get(User $user)
    {
        if (null !== $acl = $this->fetchFromCache($user)) {
            return $acl;
        }

        return $this->fetch($user);
    }
1101158
public function deleteUser(User $user)
    {
        $returnValue = $this->service->deleteUser($user);
        $this->signalDispatcher->emit(
            new DeleteUserSignal(
                array(
                    'userId' => $user->id,
                    'affectedLocationIds' => $returnValue,
                )
            )
        );

        return $returnValue;
    }
855934
public function setUser(UserInterface $user)
    {
        parent::setUser($user);

        //Store the user by email
        if($email = $user->getEmail()) {
            $this->_emails[$email] = $user;
        }

        return $this;
    }
563682
private function generateTokenForUser(UserInterface $user)
    {
        // if a token was already requested within the request interval time frame
        if (null !== $user->getPasswordResetToken()
            && $this->dateIsInRequestFrame($user->getPasswordResetTokenExpiresAt())) {
            throw new TokenAlreadyRequestedException(self::getRequestInterval());
        }
        $em = $this->getDoctrine()->getManager();

        $user->setPasswordResetToken($this->getToken());
        $expireDateTime = (new \DateTime())->add(self::getResetInterval());
        $user->setPasswordResetTokenExpiresAt($expireDateTime);
        $user->setPasswordResetTokenEmailsSent(0);

        $em->persist($user);
        $em->flush();
    }
582484
public function findByUser(UserInterface $user, $ipAddress = null)
	{
		$model = $this->createModel();
		$query = $model->where('user_id', '=', ($userId = $user->getId()));

		if ($ipAddress)
		{
			$query->where(function($query) use ($ipAddress) {
				$query->where('ip_address', '=', $ipAddress);
				$query->orWhere('ip_address', '=', NULL);
			});
		}

		if ( ! $throttle = $query->first())
		{
			$throttle = $this->createModel();
			$throttle->user_id = $userId;
			if ($ipAddress) $throttle->ip_address = $ipAddress;
			$throttle->save();
		}

		return $throttle;
	}
571405
public function fetchUser(User $user)
    {
        $response = $this->getResponse(
            sprintf('%s.json',
                $user->getUsername()
            )
        );

        return $this->hydrator->hydrate($user, $response);
    }