我的security.yml
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
my_entity_provider:
entity:
class: AppBundle:User
property: email
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
provider: my_entity_provider
anonymous: ~
form_login:
username_parameter: _email
login_path: login
check_path: login
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
#http_basic: ~
# https://symfony.com/doc/current/security/form_login_setup.html
#form_login: ~
我的控制器:
class SecurityController extends Controller{
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request, AuthenticationUtils $authUtils)
{
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
return $this->render('AppBundle:Security:login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
我的树枝: https://pastebin.com/kka6eqrH
所以我尝试使用电子邮件和密码登录,但我总是得到不好的凭证。 有人可以告诉我,我做错了什么吗?
答案 0 :(得分:0)
如果您已按照此doc检查,那么您也在查询中使用该电子邮件。
答案 1 :(得分:0)
您的username_parameter与您的树枝的输入字段不对应。
同时检查https://symfony.com/doc/current/reference/configuration/security.html#username-parameter