Skip to content

Commit

Permalink
Update Login.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Sep 9, 2024
1 parent 32753bd commit 9a1d04c
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/user/src/Services/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;
use Filament\Forms\Form;
use Filament\Http\Responses\Auth\Contracts\LoginResponse;
use Filament\Notifications\Notification;
Expand Down Expand Up @@ -88,18 +89,24 @@ protected function getLoginFormComponent(): Component

public function authenticate(): Redirector|RedirectResponse|LoginResponse|null
{
try {
$this->rateLimit(5);
} catch (TooManyRequestsException $exception) {
Notification::make()
->title(__('filament-panels::pages/auth/login.notifications.throttled.title', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]))
->danger()
->send();

return null;
if (! $this->isWhitelisted()) {
try {
$this->rateLimit(5);
} catch (TooManyRequestsException $exception) {
Notification::make()
->title(__('filament-panels::pages/auth/login.notifications.throttled.title', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => ceil($exception->secondsUntilAvailable / 60),
]))
->body(array_key_exists('body', __('filament-panels::pages/auth/login.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/login.notifications.throttled.body', [
'seconds' => $exception->secondsUntilAvailable,
'minutes' => $exception->minutesUntilAvailable,
]) : null)
->danger()
->send();

return null;
}
}

$guardName = Filament::getAuthGuard();
Expand Down

0 comments on commit 9a1d04c

Please sign in to comment.