Skip to content

Commit

Permalink
Merge pull request #11 from MarJose123/ratelimit
Browse files Browse the repository at this point in the history
Added option to disable rate limiting
  • Loading branch information
MarJose123 authored Oct 10, 2022
2 parents bbb892b + d938726 commit 7a35b2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion config/filament-lockscreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
* if `enable_redirect_to` is TRUE then after login, it will be redirected to the route setup under `redirect_route`
*/
'enable_redirect_to' => false,
'redirect_route' => 'filament.pages.dashboard'
'redirect_route' => 'filament.pages.dashboard',

/* =======================================
* RATE LIMIT
* change to false the `enable_rate_limit` to disable preventing user to input after several login failure.
*/
'rate_limit' => [
'enable_rate_limit' => true,
'rate_limit_max_count' => 5, // max count for failure login allowed.
],
];
11 changes: 9 additions & 2 deletions src/Http/Livewire/LockerScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function mount()
public function doRateLimit()
{
try {
$this->rateLimit(5);
$this->rateLimit(config('filament-lockscreen.rate_limit.rate_limit_max_count'));
} catch (TooManyRequestsException $exception) {
$this->addError(
'password', __('filament::login.messages.throttled', [
Expand All @@ -44,7 +44,14 @@ public function doRateLimit()
public function login()
{
$data = $this->form->getState();
$this->doRateLimit();

/*
* Rate Limit
*/
if(config('filament-lockscreen.rate_limit.enable_rate_limit'))
{
$this->doRateLimit();
}

if (! Filament::auth()->attempt([
'email' => Filament::auth()->user()->email,
Expand Down

0 comments on commit 7a35b2e

Please # to comment.