0

本人確認フォームを作成しましたが、フォームを送信しなくても「Bad login」というエラー メッセージが表示されます。

フォームのチェックには app/config/security.yml のアカウントを使用します。

私のコントローラー:

public function loginAction() {

    $request = $this->getRequest();
    $session = $request->getSession();
    $error = null;

    if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
        $error = "Oop's ! Bad login";
    } else {
        $error = "Oop's ! Bad login";
        $session->remove(SecurityContext::AUTHENTICATION_ERROR);
    }

    return $this->render('CmsCmsBundle:Main:Log/login.html.twig', array(
        'last_username' => $session->get(SecurityContext::LAST_USERNAME),
        'error'         => $error,
    ));
}

私の見解 :

{% if error %}
<div class="flash flash-error">
{{ error }}
</div> {% endif %}
<form action="{{ path('cms_cms_logcheck') }}" method="post">
            <div class="form-align">
                <label for="username">Login :</label>
                <input type="text" id="username" name="_username" value="{{ last_username }}" required/>
            </div>

            <div class="form-align">
                <label for="password">Pwd :</label>
                <input type="password" id="password" name="_password" required/>
            </div>

            <input type="hidden" name="_target_path" value="/private" />
            <input type="submit" class="btn btn-primary" value="Connexion">
        </form>

何か案が?

ありがとう

4

1 に答える 1