专栏'盐'在FOS用户创建

时间:2016-12-23 08:45:02

标签: doctrine-orm symfony fosuserbundle

它工作了一段时间,但现在由于某种原因它产生了异常。我有自定义用户实体,它扩展了FOS用户:

namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
...
}

我的自定义类中没有setSalt()。正如我在转储SQL查询中看到的那样,其他非自定义字段(email_canonical,enabled,password,...)设置正确。我还能检查什么?

更新

我做了作曲家更新。这是我的composer.json

"require": {
    "php": ">=5.5.9",
    "symfony/symfony": "3.2.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/monolog-bundle": "^2.8",
    "symfony/polyfill-apcu": "^1.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "hwi/oauth-bundle": "^0.5.1",
    "twig/extensions": "^1.4"
},

1 个答案:

答案 0 :(得分:8)

您必须删除架构并重新创建它。您的salt列应该被允许为null,因为在使用bcryp算法时,它确实为the salt is directly included in the password (hash)。此外是映射声明:

<field name="salt" column="salt" type="string" nullable="true" /> 

PS:和其他建议,更新所有捆绑,清除缓存,数据库及其数据......

更新:

Per dMedia,他们在最近的更新中更改了学说映射(2016年11月)

https://github.com/FriendsOfSymfony/FOSUserBundle/commit/a9a08c2daf3db38697a8bd4b6e00f42c9a33dd79#diff-36e2e6fca6f6ce7118933033f9ce8bff