app->singleton( \Laravel\Fortify\Actions\DisableTwoFactorAuthentication::class, DisableTwoFactorAuthentication::class, ); } /** * Bootstrap any application services. */ public function boot(): void { Fortify::createUsersUsing(CreateNewUser::class); RateLimiter::for('login', function (Request $request) { $username = $request->input('username'); $ip = $request->ip(); return Limit::perMinute(5)->by((is_string($username) ? $username : '') . (is_string($ip) ? $ip : '')); }); RateLimiter::for('two-factor', function (Request $request) { $loginId = $request->session()->get('login.id'); return Limit::perMinute(5)->by(is_string($loginId) ? $loginId : ''); }); /** @phpstan-ignore argument.type */ Fortify::loginView(fn () => view('auth.login', [ 'articles' => WebsiteArticle::latest('id') ->take(4) ->has('user') ->with('user:id,username,look') ->get(), 'photos' => CameraWeb::latest('id') ->take(4) ->with('user:id,username,look') ->get(), ])); Fortify::registerView(function (Request $request) { if (setting('disable_registration') === '1') { return to_route('welcome')->withErrors([ 'register' => __('Registration is currently disabled.'), ]); } return view('auth.register', [ 'referral_code' => $request->route('referral_code'), 'articles' => WebsiteArticle::latest('id') ->take(4) ->has('user') ->with('user:id,username,look') ->get(), 'photos' => CameraWeb::latest('id') ->take(2) ->with('user:id,username,look') ->get(), ]); }); Fortify::confirmPasswordView(fn () => view('auth.passwords.confirm')); Fortify::twoFactorChallengeView(fn () => view('auth.two-factor-challenge')); $this->authenticate(); } private function authenticate(): void { Fortify::authenticateThrough(fn () => array_filter([ config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class, Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorConfirmed::class : null, AttemptToAuthenticate::class, PrepareAuthenticatedSession::class, ])); } }