0

私は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'), 
        )
    );
}

ログインページ

4

1 に答える 1