From e04136524c1bf74c9bcfca8dc471a1339f94f537 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 11 Jul 2016 11:55:50 +0200 Subject: [PATCH] Fix the retrieval of the last username when using forwarding --- .../Security/Http/Authentication/AuthenticationUtils.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index 4d5c71aa5c..c6397e8ca1 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -65,7 +65,13 @@ class AuthenticationUtils */ public function getLastUsername() { - $session = $this->getRequest()->getSession(); + $request = $this->getRequest(); + + if ($request->attributes->has(Security::LAST_USERNAME)) { + return $request->attributes->get(Security::LAST_USERNAME); + } + + $session = $request->getSession(); return null === $session ? '' : $session->get(Security::LAST_USERNAME); }