forked from fa/breadcrumb-the-shire
fix(session): preserve intended URL across session timeout with remember-me
Session timeout redirected to /de/login?return_to=... but the remember-me cookie was not cleared by logoutDueToSessionTimeout(). On the next request, autoLoginFromCookie() silently re-logged the user in, causing the MintyPHP router to resolve the login route to pages/index().php (dashboard) instead of the login action — the intended URL redirect logic never executed. Fix: intercept ?return_to= immediately after successful auto-login in index.php and redirect to the sanitized route path. Also harden the login flow with hidden return_to form fields and POST body fallback for cases without remember-me. Additional improvements in this commit: - Convert stored REQUEST_URI to router-compatible path (strip leading slash and locale prefix) via IntendedUrlService::toRoutePath() - Consolidate duplicate CSRF data attributes into shared data-csrf-key and data-csrf-token on <html> element - Add tenant branding (logo) to auth pages via appAuthLogoUrl() helper Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -186,7 +186,7 @@ class IntendedUrlServiceTest extends TestCase
|
||||
|
||||
// ── retrieveAndForget ─────────────────────────────────────
|
||||
|
||||
public function testRetrieveAndForgetReturnsStoredUrlAndRemovesIt(): void
|
||||
public function testRetrieveAndForgetReturnsRoutePathAndRemovesIt(): void
|
||||
{
|
||||
$this->session->expects($this->any())
|
||||
->method('get')
|
||||
@@ -197,7 +197,35 @@ class IntendedUrlServiceTest extends TestCase
|
||||
->method('remove')
|
||||
->with('intended_url');
|
||||
|
||||
$this->assertSame('/admin/users', $this->service->retrieveAndForget($this->session));
|
||||
$this->assertSame('admin/users', $this->service->retrieveAndForget($this->session));
|
||||
}
|
||||
|
||||
public function testRetrieveAndForgetStripsLocalePrefix(): void
|
||||
{
|
||||
$this->session->expects($this->any())
|
||||
->method('get')
|
||||
->with('intended_url')
|
||||
->willReturn('/de/admin/users/edit/5');
|
||||
|
||||
$this->session->expects($this->once())
|
||||
->method('remove')
|
||||
->with('intended_url');
|
||||
|
||||
$this->assertSame('admin/users/edit/5', $this->service->retrieveAndForget($this->session));
|
||||
}
|
||||
|
||||
public function testRetrieveAndForgetPreservesQueryString(): void
|
||||
{
|
||||
$this->session->expects($this->any())
|
||||
->method('get')
|
||||
->with('intended_url')
|
||||
->willReturn('/de/admin/users?page=2&sort=name');
|
||||
|
||||
$this->session->expects($this->once())
|
||||
->method('remove')
|
||||
->with('intended_url');
|
||||
|
||||
$this->assertSame('admin/users?page=2&sort=name', $this->service->retrieveAndForget($this->session));
|
||||
}
|
||||
|
||||
public function testRetrieveAndForgetReturnsFallbackWhenNoUrlStored(): void
|
||||
|
||||
Reference in New Issue
Block a user