symfony ldap总是重定向到登录页面

时间:2013-11-13 12:16:19

标签: php symfony login

我有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'), 
        )
    );
}

login page

1 个答案:

答案 0 :(得分:0)

最后我找到了答案。只需更改会话文件中的权限即可。我的会话位于app/sessions/。所以我通过运行此命令sudo chmod -R 777 app/sessions/来更改权限。但首先,您必须查看error.log