2012-11-28 31 views
14

当我提交了连接形式,我有这样的错误(我用FOSUserBundle最新版本):无编码器已经配置了帐户fosUserBundle symfony2.1

No encoder has been configured for account "MyApp\UtilisateurBundle\Entity\Utilisateur 

这里是我的实体:

<?php 
namespace MyApp\UtilisateurBundle\Entity; 
use FOS\UserBundle\Entity\User as BaseUser; 
use Doctrine\ORM\Mapping as ORM; 
/** 
* @ORM\Entity 
*/ 
class Utilisateur extends BaseUser 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\generatedValue(strategy="AUTO") 
    */ 
    protected $id; 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 
} 

这里是我的应用程序/配置/ security.yml:

imports: 
- { resource: "@MyAppFilmothequeBundle/Resources/config/security.yml" } 

这里是我的src/MyApp的/ FilmothequeBundle/Ressou的RCE /配置/ security.yml:

security: 
providers: 
    fos_userbundle: 
     id: fos_user.user_manager 

firewalls: 
    main: 
     pattern:  .* 
     form_login: 
      provider:  fos_userbundle 
      login_path:  /myapp/login 
      use_forward: false 
      check_path:  /myapp/login_check 
      failure_path: null 
      default_target_path: /myapp 
     logout: 
      path: /myapp/logout 
      target: /myapp 
     anonymous: true 

我跟着这个教程这样做:http://j-place.developpez.com/tutoriels/php/ameliorez-vos-applications-developpees-avec-symfony2/#LVI-B-1

我怎样才能做到这一点? 预先感谢您

回答

29

尝试security.yml添加此至密钥

encoders: 
     FOS\UserBundle\Model\UserInterface: sha512 

所以它的

security: 
    encoders: 
     FOS\UserBundle\Model\UserInterface: sha512 

    providers: 
     ... 

    firewalls: 
     ... 
+0

谢谢你,它的工作原理 – user201892

相关问题