1

sylius 使用除非电子邮件连接到管理,

我想同时使用用户名和电子邮件,但它不起作用

安全.yml

      security:
          providers:
              fos_userbundle:
                  id: fos_user.user_provider.username_email
          encoders:
              FOS\UserBundle\Model\UserInterface: sha512
          firewalls:
              administration:
                  switch_user: true
                  context:     user
                  pattern:     /administration/.*
                  form_login:
                      provider:     fos_userbundle
                      login_path:   /administration/login
                      check_path:   /administration/login-check
                      failure_path: /administration/login
                      default_target_path: /administration/dashboard
                      use_forward:  false
                      use_referer:  true
                  logout:
                      path:   /administration/logout
                      target: /administration/login
                  anonymous: true
4

1 回答 1

1

您是否检查了用户名与电子邮件不同的天气?在 Sylius 中,用户获得与他的电子邮件地址相同的用户名,如您在

Sylius\Bundle\CoreBundle\Model\User


class User{
...

public function setEmail($email)
{
    parent::setEmail($email);
    $this->setUsername($email);

    return $this;
}

public function setEmailCanonical($emailCanonical)
{
    parent::setEmailCanonical($emailCanonical);
    $this->setUsernameCanonical($emailCanonical);

    return $this;
}
}
于 2013-10-30T15:53:46.263 回答