Beispiel #1
0
	/**
	 * Finds a throttler by the given user ID.
	 *
	 * @param  mixed   $id
	 * @param  string  $ipAddress
	 * @return \Cartalyst\Sentry\Throttling\ThrottleInterface
	 */
	public function findByUserId($id, $ipAddress = null)
	{
		$user  = $this->userProvider->findById($id);
		$user_id = $user->id;

		$model = $this->createModel();
		$query = $model->where('user_id', '=', $user_id);

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

		$throttle = $query->find();

		if ( ! $throttle->loaded() )
		{

			$throttle = $this->createModel();
			$values = array(
				'user_id' => $user->id
			);
			if ($ipAddress) $values['ip_address'] = $ipAddress;
			$throttle->values($values);
			$throttle->save();
		}

		return $throttle;
	}
Beispiel #2
0
 /**
  * Finds a user by the given user ID.
  *
  * @param  mixed  $id
  * @return \Cartalyst\Sentry\Users\UserInterface
  * @throws \Cartalyst\Sentry\Users\UserNotFoundException
  */
 public function findUserById($id)
 {
     return $this->userProvider->findById($id);
 }
Beispiel #3
0
 /**
  * Finds a throttler by the given user ID.
  *
  * @param  mixed   $id
  * @param  string  $ipAddress
  * @return \Cartalyst\Sentry\Throttling\ThrottleInterface
  */
 public function findByUserId($id, $ipAddress = null)
 {
     return $this->findByUser($this->userProvider->findById($id), $ipAddress);
 }