mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-27 23:24:07 +00:00
Fix logout/re-login CSRF mismatch and stale token issues
Cherry-picked from v3.0 branch. Three fixes: 1. Refresh CSRF cookie after logout (auth.js) 2. Clear auth.token and selectedCompany from localStorage on logout (auth.js) 3. Invalidate session and regenerate CSRF token on server-side logout (web.php) Without these, logging out and back in as a different user would fail with CSRF token mismatch and 401 Unauthenticated errors because the browser held stale session cookies and localStorage tokens.
This commit is contained in:
@@ -34,6 +34,9 @@ Route::post('login', [LoginController::class, 'login']);
|
||||
|
||||
Route::post('auth/logout', function () {
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
request()->session()->invalidate();
|
||||
request()->session()->regenerateToken();
|
||||
});
|
||||
|
||||
// Customer auth
|
||||
|
||||
Reference in New Issue
Block a user