2012-11-28 30 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

相關問題