55use Illuminate \Cache \RateLimiting \Limit ;
66use Illuminate \Http \Request ;
77use Illuminate \Support \Facades \RateLimiter ;
8- use Illuminate \Support \Facades \Route ;
98use Illuminate \Support \ServiceProvider ;
109use Illuminate \Support \Str ;
1110use Inertia \Inertia ;
11+ use Laravel \Fortify \Features ;
1212use Laravel \Fortify \Fortify ;
1313
1414class FortifyServiceProvider extends ServiceProvider
@@ -25,9 +25,19 @@ 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 ]));
3343
@@ -38,7 +48,13 @@ public function boot(): void
3848 Fortify::twoFactorChallengeView (fn () => Inertia::render ('auth/TwoFactorChallenge ' ));
3949
4050 Fortify::confirmPasswordView (fn () => Inertia::render ('auth/ConfirmPassword ' ));
51+ }
4152
53+ /**
54+ * Configure rate limiting.
55+ */
56+ private function configureRateLimiting (): void
57+ {
4258 RateLimiter::for ('two-factor ' , function (Request $ request ) {
4359 return Limit::perMinute (5 )->by ($ request ->session ()->get ('login.id ' ));
4460 });
0 commit comments