switch loginController to symfony3

This commit is contained in:
Julien Fastré 2018-04-19 20:03:10 +02:00
parent 06bff38701
commit 2bcaaac60c

View File

@ -17,29 +17,12 @@ class LoginController extends Controller
*/ */
public function loginAction(Request $request) public function loginAction(Request $request)
{ {
$helper = $this->get('security.authentication_utils');
$session = $request->getSession();
if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(
SecurityContextInterface::AUTHENTICATION_ERROR
);
} elseif (null !== $session && $session->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
$error = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
$session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
} else {
$error = '';
}
$lastUsername = (null === $session) ?
'' : $session->get(SecurityContextInterface::LAST_USERNAME);
return $this->render('ChillMainBundle:Login:login.html.twig', array( return $this->render('ChillMainBundle:Login:login.html.twig', array(
'last_username' => $lastUsername, 'last_username' => $helper->getLastUsername(),
'error' => (empty($error)) ? $error : $error->getMessage() 'error' => $helper->getLastAuthenticationError()
)); ));
} }
public function LoginCheckAction(Request $request) public function LoginCheckAction(Request $request)