fixed rate limiter for laravel 10

This commit is contained in:
Denis Duliçi 2023-03-22 00:23:41 +03:00
parent a2f882a36e
commit 318082228e

View File

@ -18,14 +18,14 @@ trait Emails
$limit_per_month = config('app.throttles.email.month'); $limit_per_month = config('app.throttles.email.month');
$decay_per_month = 60 * 60 * 24 * 30; $decay_per_month = 60 * 60 * 24 * 30;
$can_send = RateLimiter::attempt($key_per_month, $limit_per_month, fn() => '', $decay_per_month); $can_send = RateLimiter::attempt($key_per_month, $limit_per_month, fn() => null, $decay_per_month);
if ($can_send) { if ($can_send) {
// Check if the user has reached the limit of emails per minute // Check if the user has reached the limit of emails per minute
$key_per_minute = 'email-minute:' . user()->id; $key_per_minute = 'email-minute:' . user()->id;
$limit_per_minute = config('app.throttles.email.minute'); $limit_per_minute = config('app.throttles.email.minute');
$can_send = RateLimiter::attempt($key_per_minute, $limit_per_minute, fn() => ''); $can_send = RateLimiter::attempt($key_per_minute, $limit_per_minute, fn() => null);
} }
if ($can_send) { if ($can_send) {