我想针对数据库创建 SF2 身份验证,我使用了 SF2 的官方文档http://symfony.com/doc/2.0/cookbook/security/entity_provider.html,问题是检查不起作用,我不'不知道怎么回事,我没有收到任何错误,输入用户信息后我仍然在同一页面/登录,没有错误,我真的不明白。
安全.yml
security:
encoders:
TEST\UserBundle\Entity\User:
algorithm: sha512
encode-as-base64: true
iterations: 10
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
main:
entity: { class: TESTUserBundle:User, property: username }
firewalls:
login:
pattern: ^/(login|reset|accueil)
anonymous: true
main:
pattern: /.*
form_login:
check_path: /check_login
login_path: /login
logout:
path: /logout
target: /login
security: true
anonymous: false
access_control:
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
#- { path: ^/_internal, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
#- { path: ^/admin, roles: ROLE_ADMIN }
问题是错误始终为空,这是我的登录表单
{% if error == 1 %}
<span class="pw-alert">E-mail et/ou mot de passe erroné(s)</span>
{% endif %}
<form action="{{ path('_security_check_user') }}" method="POST">
<div>
<label for="username">Username:</label>
<input type="email" id="username" name="_username" value="{{ last_username }}" />
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" name="_password" />
</div>
<input type="submit" value="Se connecter" name="login"/>
</div>
</form>