我有 symfony 网站。这是我的登录表单。假设我输入了用户名、密码、安全码。我的问题是每次单击登录按钮时,它总是重定向到登录页面,如下图所示,尽管我的数据是对还是错。最糟糕的是,当我提交错误的数据时,没有显示错误。我试图清除缓存并更新我的作曲家。但这些都不起作用。这是我的登录控制器
public function loginAction()
{
$request = $this->getRequest();
$session = $this->get('session');
$session->set('login_referer', $request->server->get('HTTP_REFERER'));
if ($session->has(AuthenticationConstant::AUTHENTICATION_ATTEMPTS_EXCEEDED)) {
$error = $session->get(AuthenticationConstant::AUTHENTICATION_ATTEMPTS_EXCEEDED);
} else if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)){
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
}
// remove session error message because if not remove, the error will saved in session
//so even there's no error, it stills display an error
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(AuthenticationConstant::AUTHENTICATION_ATTEMPTS_EXCEEDED);
return $this->render('AcmeGlobalBundle:Security:login.html.twig' , array(
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
'token' => $this->generateToken(),
'captcha' => $this->get('mikroskil_captcha'),
)
);
}