fix(session):Added Session::flush() + Session::regenerate() at the en…#118
fix(session):Added Session::flush() + Session::regenerate() at the en…#118
Conversation
…d of AuthService::logout() after all other cleanup operations complete. This ensures: 1. invalidateSession() captures the session ID for the cache blacklist before flush 2. principal_service->clear() and security_context_service->clear() run first (now redundant but harmless) 3. Auth::logout() clears Laravel auth state before the session is destroyed 4. Session::flush() removes ALL session data in one operation 5. Session::regenerate() creates a fresh session ID to prevent fixation
📝 WalkthroughWalkthroughSession management operations are being consolidated from multiple controllers into the AuthService. Session::flush() and Session::regenerate() calls are removed from HomeController and UserController, then centralized in AuthService::logout(). A comprehensive test suite validates the refactored behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/AuthServiceLogoutTest.php (1)
79-81: Minor:debug_msgis not a Laravel Log facade method.Line 81 mocks
debug_msgwhich doesn't exist on Laravel's Log facade. This is harmless since Mockery will just ignore calls that don't happen, but it's unnecessary noise.🧹 Suggested cleanup
// Log calls are always allowed $this->log_mock->shouldReceive('debug')->zeroOrMoreTimes(); - $this->log_mock->shouldReceive('debug_msg')->zeroOrMoreTimes();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/AuthServiceLogoutTest.php` around lines 79 - 81, Remove the unnecessary mock for the non-existent Log method by deleting the shouldReceive('debug_msg') line in the test setup where $this->log_mock is configured; keep the valid shouldReceive('debug')->zeroOrMoreTimes() call so logging remains allowed, and ensure no other tests rely on a custom debug_msg expectation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/AuthServiceLogoutTest.php`:
- Around line 79-81: Remove the unnecessary mock for the non-existent Log method
by deleting the shouldReceive('debug_msg') line in the test setup where
$this->log_mock is configured; keep the valid
shouldReceive('debug')->zeroOrMoreTimes() call so logging remains allowed, and
ensure no other tests rely on a custom debug_msg expectation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 302357c8-3e6c-4ae2-a3d8-2b1246bc4234
📒 Files selected for processing (4)
app/Http/Controllers/HomeController.phpapp/Http/Controllers/UserController.phpapp/libs/Auth/AuthService.phptests/AuthServiceLogoutTest.php
💤 Files with no reviewable changes (2)
- app/Http/Controllers/UserController.php
- app/Http/Controllers/HomeController.php
Summary by CodeRabbit
Chores
Tests