Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51fa731

Browse files
weaverryanfabpot
authored andcommitted
migrating session for UsernamePasswordJsonAuthenticationListener
1 parent ab384b0 commit 51fa731

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ private function onSuccess(Request $request, TokenInterface $token)
141141
$this->logger->info('User has been authenticated successfully.', array('username' => $token->getUsername()));
142142
}
143143

144+
$this->migrateSession($request);
145+
144146
$this->tokenStorage->setToken($token);
145147

146148
if (null !== $this->eventDispatcher) {
@@ -184,4 +186,15 @@ private function onFailure(Request $request, AuthenticationException $failed)
184186

185187
return $response;
186188
}
189+
190+
private function migrateSession(Request $request)
191+
{
192+
if (!$request->hasSession() || !$request->hasPreviousSession()) {
193+
return;
194+
}
195+
// Destroying the old session is broken in php 5.4.0 - 5.4.10
196+
// See https://bugs.php.net/63379
197+
$destroy = \PHP_VERSION_ID < 50400 || \PHP_VERSION_ID >= 50411;
198+
$request->getSession()->migrate($destroy);
199+
}
187200
}

0 commit comments

Comments
 (0)