Skip to content

Commit 7aa0ce0

Browse files
committed
Refactor FortifyServiceProvider to modularize view and rate-limiting configurations
1 parent e8582a8 commit 7aa0ce0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

app/Providers/FortifyServiceProvider.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use Illuminate\Cache\RateLimiting\Limit;
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\RateLimiter;
8-
use Illuminate\Support\Facades\Route;
98
use Illuminate\Support\ServiceProvider;
109
use Illuminate\Support\Str;
1110
use Inertia\Inertia;
11+
use Laravel\Fortify\Features;
1212
use Laravel\Fortify\Fortify;
1313

1414
class FortifyServiceProvider extends ServiceProvider
@@ -25,14 +25,32 @@ public function register(): void
2525
* Bootstrap any application services.
2626
*/
2727
public function boot(): void
28+
{
29+
$this->configureViews();
30+
$this->configureRateLimiting();
31+
}
32+
33+
/**
34+
* Configure Fortify views.
35+
*/
36+
private function configureViews(): void
2837
{
2938
Fortify::loginView(fn (Request $request) => Inertia::render('auth/Login', [
30-
'canResetPassword' => Route::has('password.request'),
39+
'canResetPassword' => Features::enabled(Features::resetPasswords()),
40+
'canRegister' => Features::enabled(Features::registration()),
3141
'status' => $request->session()->get('status'),
3242
]));
43+
3344
Fortify::twoFactorChallengeView(fn () => Inertia::render('auth/TwoFactorChallenge'));
45+
3446
Fortify::confirmPasswordView(fn () => Inertia::render('auth/ConfirmPassword'));
47+
}
3548

49+
/**
50+
* Configure rate limiting.
51+
*/
52+
private function configureRateLimiting(): void
53+
{
3654
RateLimiter::for('two-factor', function (Request $request) {
3755
return Limit::perMinute(5)->by($request->session()->get('login.id'));
3856
});

0 commit comments

Comments
 (0)