Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 20241112 #812

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/Http/Requests/Auth/LoginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Container\Attributes\Config;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
Expand All @@ -12,6 +13,11 @@

class LoginRequest extends FormRequest
{
public function __construct(
#[Config('auth.rate_limit.max_attempts', 5)] protected int $maxAttempts,
#[Config('auth.rate_limit.decay_seconds', 600)] protected int $decaySeconds
) {}

/**
* Determine if the user is authorized to make this request.
*
Expand Down Expand Up @@ -51,7 +57,7 @@ public function authenticate()
$credentials['active'] = true;

if (! Auth::attempt($credentials, $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey(), 600);
RateLimiter::hit($this->throttleKey(), $this->decaySeconds);

// check if this user has verified their email address
$user = User::where('email', $this->email)->first();
Expand All @@ -78,7 +84,7 @@ public function authenticate()
*/
public function ensureIsNotRateLimited()
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
if (! RateLimiter::tooManyAttempts($this->throttleKey(), $this->maxAttempts)) {
return;
}

Expand Down
Loading
Loading