Skip to content

Commit 259a2b7

Browse files
committed
bug #3866 [Book][Security]fixed Login when there is no session. (aitboudad)
This PR was merged into the 2.3 branch. Discussion ---------- [Book][Security]fixed Login when there is no session. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all |Fixed tickets | - Commits ------- a7b8bc4 [Security]fixed Login when there is no session.
2 parents b32ec15 + a7b8bc4 commit 259a2b7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

book/security.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,21 @@ Next, create the controller that will display the login form::
449449
$error = $request->attributes->get(
450450
SecurityContextInterface::AUTHENTICATION_ERROR
451451
);
452-
} else {
452+
} elseif (null !== $session && $session->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
453453
$error = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
454454
$session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
455+
} else {
456+
$error = '';
455457
}
458+
459+
// last username entered by the user
460+
$lastUsername = (null === $session) ? '' : $session->get(SecurityContextInterface::LAST_USERNAME);
456461

457462
return $this->render(
458463
'AcmeSecurityBundle:Security:login.html.twig',
459464
array(
460465
// last username entered by the user
461-
'last_username' => $session->get(SecurityContextInterface::LAST_USERNAME),
466+
'last_username' => $lastUsername,
462467
'error' => $error,
463468
)
464469
);

0 commit comments

Comments
 (0)