Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede committed Feb 12, 2024
1 parent 8a8bb61 commit 7fb4ad4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions system/routing/throttle.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public static function check($max_attempts, $decay_minutes = 1)
$decay_minutes = (int) $decay_minutes;
$decay_minutes = ($decay_minutes < 1) ? 1 : $decay_minutes;
$key = static::key();
$data = Cache::get($key);

if (!Cache::has($key)) {
if (!$data) {
$data = [
'limit' => $max_attempts,
'remaining' => $max_attempts,
Expand All @@ -40,12 +41,9 @@ public static function check($max_attempts, $decay_minutes = 1)
'key' => $key,
'ip' => Request::ip(),
];

Cache::put($key, $data, $decay_minutes);
}

$data = Cache::get($key);

if ($data['remaining'] > 0) {
$data['remaining'] = $data['remaining'] - 1;
Cache::put($key, $data, $decay_minutes);
Expand Down

0 comments on commit 7fb4ad4

Please sign in to comment.