diff --git a/Controller/LoginController.php b/Controller/LoginController.php index 72f8a28fb..bba6f13d5 100644 --- a/Controller/LoginController.php +++ b/Controller/LoginController.php @@ -17,29 +17,12 @@ class LoginController extends Controller */ public function loginAction(Request $request) { - - $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); - + $helper = $this->get('security.authentication_utils'); return $this->render('ChillMainBundle:Login:login.html.twig', array( - 'last_username' => $lastUsername, - 'error' => (empty($error)) ? $error : $error->getMessage() + 'last_username' => $helper->getLastUsername(), + 'error' => $helper->getLastAuthenticationError() )); - } public function LoginCheckAction(Request $request)