protected function authenticate(Request $request, $templatepath)
{
if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
throw new \Exception("Error Processing Request", 1);
}
if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
throw new \Exception("Error Processing Request", 1);
}
$session = $request->getSession();
# get the login error if there is one
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render($templatepath, array('last_username' => $session->get(SecurityContext::LAST_USERNAME), 'error' => $error));
}