/** * Get the throttle provider for a given user * * @author ZZK * @link http://verecom.com * * @param $id * * @throws UserNotFoundException * * @return \Cartalyst\Sentry\Throttling\ThrottleInterface */ public function getUserThrottle($id) { try { return $this->sentry->findThrottlerByUserId($id); } catch (SentryUserNotFoundException $e) { throw new UserNotFoundException($e->getMessage()); } }
/** * Unsuspend the user and give him a new password * * @param User $user * @param string $reset_code The password reset code * @throws PasswordResetFailedException * @return string Returns the new password on success */ protected function unsuspendUserAndResetPassword($user, $reset_code) { $throttle = $this->sentry->findThrottlerByUserId($user->getId()); $throttle->unsuspend(); $new_password = $this->mockably->str_random(16); if ($user->attemptResetPassword($reset_code, $new_password)) { return $new_password; } else { throw new PasswordResetFailedException(); } }
/** * Finds a throttler by the given user ID. * * @param mixed $id * @param string $ipAddress * @return \Cartalyst\Sentry\Throttling\ThrottleInterface * @static */ public static function findThrottlerByUserId($id, $ipAddress = null) { return \Cartalyst\Sentry\Sentry::findThrottlerByUserId($id, $ipAddress); }