私はsymfonyのドキュメンテーションの例について私のWebページにログインするのに少し問題があります。それは仕事ですが、キャッシュをクリアした後、もう一度作業します。初めてセッションタイムアウトに失敗したか、またはクッキーを無効にしました。symfonyのシンプルなログイン
{% if is_granted('ROLE_USER') %}
<div class="content">
<div class="starter-template">
{% block body %}{% endblock %}
</div>
</div>
{% else %}
<div class="container">
<div class="row">
<div class="col-md-offset-5 col-md-3">
<div class="form-login">
<h4>Welcome back.</h4>
<form action="{{ path('login') }}" method="post">
<input type="text" name="_username" id="userName" class="form-control input-sm chat-input" placeholder="username" />
</br>
<input type="password" name="_password" id="userPassword" class="form-control input-sm chat-input" placeholder="password" />
</br>
<div class="wrapper">
<span class="group-btn">
<button type="submit" href="#" class="btn btn-primary btn-md">login <i class="fa fa-sign-in"></i></button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
{% endif %}
とログインアクションをbase.html.twigだ:
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
私はこのアクションにリダイレクトしますが、何も私を助けていないリターンを試してみてください。
/loginページでログインする場合は、その作業はokeyです。しかし、私はどのようにどのようにbase.htmlで使用する必要があります。
ソナタ管理バンドルを使用していますか? –
いいえ、それはhttp://symfony.com/doc/current/security/form_login_setup.htmlからのログイン例です。別のプロジェクトでは、ログイン/ログインページを使用してログイン後にリダイレクトすると動作しますが、今はログインデータを送信します〜/ホームページからログインしてください –