From 40b08f22ffb550306589035c9087c186316238d4 Mon Sep 17 00:00:00 2001 From: shakilofficial0 Date: Wed, 20 Sep 2023 21:02:19 +0600 Subject: [PATCH] attempting action loggout --- app/Http/Responses/LogoutResponse.php | 37 ++++++++++++++++++++++++ app/Providers/FortifyServiceProvider.php | 5 ++++ 2 files changed, 42 insertions(+) create mode 100644 app/Http/Responses/LogoutResponse.php diff --git a/app/Http/Responses/LogoutResponse.php b/app/Http/Responses/LogoutResponse.php new file mode 100644 index 0000000..6700d48 --- /dev/null +++ b/app/Http/Responses/LogoutResponse.php @@ -0,0 +1,37 @@ + now(), + ], + [ + '_token' => $request->session()->token(), + 'action_type' => 'login' + ] + ); + return $request->wantsJson() + ? new JsonResponse('', 204) + : redirect()->route('login'); + } +} diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index c5c87c1..2b55220 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -41,6 +41,11 @@ public function boot(): void RateLimiter::for('two-factor', function (Request $request) { return Limit::perMinute(5)->by($request->session()->get('login.id')); }); + + $this->app->singleton( + \Laravel\Fortify\Contracts\LogoutResponse::class, + \App\Http\Responses\LogoutResponse::class + ); }