Search code examples
fosuserbundlesymfony-3.4

FOS User bundle : Column 'salt' cannot be null during change password


Previously, the app was in PHP7.0, SF 3.1, and FOS/UserBundle 2.0.

After the migration to PHP7.2 with SF 3.4 and FOS/UserBundle 2.1, during a change password, I encounter that:

$ bin/console fos:user:change-password toto pass1234

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null" ["exception" => Doctrine\DBAL\Exception\NotNullConstraintViolationException { …},"command" => "fos:user:change-password toto pass1234","message" => """  An exception occurred while executing 'UPDATE fos_user SET salt = ?, password = ? WHERE id = ?' with params [null, "$2y$13$LOb\/************************************wof0QpTGGpzGi", 2]:\n  \n  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null  """] []

In AbstractMySQLDriver.php line 123:

  An exception occurred while executing 'UPDATE fos_user SET salt = ?, password = ? WHERE id = ?' with params [null, "$2y$13$LOb\/************************************wof0QpTGGpzGi", 2]:                                            

  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null                                                                      


In PDOStatement.php line 144:

  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null                                                                      


In PDOStatement.php line 142:

  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null                                                                      


fos:user:change-password [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <username> <password>

Solution

  • Solved!

    I edited file app/config/security.yml and replace the value of security.encoders.FOS\UserBundle\Model\UserInterface (which was bcrypt) with argon2i.

    Then I cleared the cache, retried, and that worked!

    https://symfony.com/doc/current/reference/configuration/security.html#reference-security-argon2i