Skip to content

Commit

Permalink
Merge pull request #92 from Lakshan-Madushanka/Fix-logout-vulnerabili…
Browse files Browse the repository at this point in the history
…ties

Fix logout vulnerabilities
  • Loading branch information
tnylea authored Jul 11, 2024
2 parents fd4669e + 34dd97d commit ad20846
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Http/Controllers/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@
namespace Devdojo\Auth\Http\Controllers;

use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LogoutController
{
public function __invoke(): RedirectResponse
public function __invoke(Request $request): RedirectResponse
{
Auth::logout();

$this->clearTraces($request);

return redirect()->route('home');
}

public function getLogout()
public function getLogout(Request $request)
{
Auth::logout();
Session()->flush();

$this->clearTraces($request);

return redirect('/');
}

private function clearTraces(Request $request): void
{
$request->session()->invalidate();
$request->session()->regenerateToken();
}
}

0 comments on commit ad20846

Please sign in to comment.