/** * 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; }
/** * 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); }
/** * 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); }