Skip to content

Commit

Permalink
attempting action loggout
Browse files Browse the repository at this point in the history
  • Loading branch information
shakilofficial0 committed Sep 20, 2023
1 parent 9f8b6f3 commit 40b08f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
37 changes: 37 additions & 0 deletions app/Http/Responses/LogoutResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Http\Responses;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Laravel\Fortify\Contracts\LogoutResponse as LogoutResponseContract;
use Symfony\Component\HttpFoundation\Response;
use DB;
use App\Models\UserDumpLog;


class LogoutResponse implements LogoutResponseContract
{
/**
* Create an HTTP response that represents the object.
*
* @param Request $request
*
* @return Response
*/
public function toResponse($request)
{
UserDumpLog::update(
[
'loggedout_at' => now(),
],
[
'_token' => $request->session()->token(),
'action_type' => 'login'
]
);
return $request->wantsJson()
? new JsonResponse('', 204)
: redirect()->route('login');
}
}
5 changes: 5 additions & 0 deletions app/Providers/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}


Expand Down

0 comments on commit 40b08f2

Please sign in to comment.