Example #1
0
 /**
  * Show the application login form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getLogin()
 {
     //dd("loaded");
     // get the current request object
     //Throttle::clear();
     $request = Request::getFacadeRoot();
     //dd($request);
     // throttler object for that request, X, Y
     // X = tries, Y = minutes
     $throttler = Throttle::get($request, Config::get('kagi.throttle', '3'), Config::get('kagi.time_out', '2'));
     //dd($throttler);
     /*
     // check if we've gone over the limit
     		var_dump($throttler->check());
     // implement Countable
     		var_dump($throttler->count());
     // the attempt function will hit the throttle, then return check
     		var_dump(Throttle::attempt($request));
     */
     // Check throttle, return with error
     if (!Throttle::attempt($request, 5)) {
         Flash::error(trans('kotoba::auth.error.not_approved'));
     }
     return Theme::View('modules.kagi.auth.login');
 }
Example #2
0
 private function isThrottled()
 {
     if (!($config = $this->config['throttle'])) {
         return false;
     }
     $throttle = explode(':', $config);
     return !Throttle::attempt(['ip' => gethostname(), 'route' => $this->config['class'] . $this->worker], $throttle[0], $throttle[1]);
 }
Example #3
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $limit = 10;
     // request limit
     $time = 30;
     // ban time
     if (!Throttle::attempt($request, $limit, $time)) {
         throw new TooManyRequestsHttpException($time * 60, 'Rate limit exceed.');
     }
     return $next($request);
 }
 /**
  * Check if the called function is throttled.
  *
  * @param [type] $conn    [description]
  * @param [type] $setting [description]
  *
  * @return bool [description]
  */
 private function isThrottled($conn, $setting)
 {
     $connectionThrottle = explode(':', config(sprintf('ratchet.throttle.%s', $setting)));
     return !Throttle::attempt(['ip' => $conn->remoteAddress, 'route' => $setting], $connectionThrottle[0], $connectionThrottle[1]);
 }
Example #5
0
    // we can hit the throttle later on in the if validation passes
    if (!Throttle::check($request, 10, 1)) {
        throw new TooManyRequestsHttpException(60, 'Rate limit exceeded.');
    }
});
$router->filter('throttle.login', function ($route, $request) {
    // check if we've reached the rate limit, but don't hit the throttle yet
    // we can hit the throttle later on in the if validation passes
    if (!Throttle::check($request, 10, 10)) {
        return Redirect::route('account.login')->withInput()->with('error', 'You have made too many login requests. Please try again in 10 minutes.');
    }
});
$router->filter('throttle.activate', function ($route, $request) {
    // check if we've reached the rate limit, and hit the throttle
    // no validation is required, we should always hit the throttle
    if (!Throttle::attempt($request, 10, 10)) {
        return Redirect::route('account.login')->withInput()->with('error', 'You have made too many activation requests. Please try again in 10 minutes.');
    }
});
$router->filter('throttle.resend', function ($route, $request) {
    // check if we've reached the rate limit, but don't hit the throttle yet
    // we can hit the throttle later on in the if validation passes
    if (!Throttle::check($request, 5, 30)) {
        return Redirect::route('account.resend')->withInput()->with('error', 'You have been suspended from resending activation emails. Please contact support.');
    }
});
$router->filter('throttle.reset', function ($route, $request) {
    // check if we've reached the rate limit, but don't hit the throttle yet
    // we can hit the throttle later on in the if validation passes
    if (!Throttle::check($request, 5, 30)) {
        return Redirect::route('account.reset')->withInput()->with('error', 'You have been suspended from resetting passwords. Please contact support.');