bardius / BardisCMS

BardisCMS is a Symfony2 CMS(v2.8.14) distribution with integrated Zurb Foundation 6 (Grunt, Bower & Babel included) for front end and all the major bundles pre-configured (Sonata Admin, User, Media, FOSUser, KnpMenu, Guzzle 6) combined with extra bundles to provide a fully functional out of the box CMS for responsive websites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use fos:user:create

Guilllaum opened this issue · comments

When we want to create user or super-admin in command line, there is a bug:

`$ php app/console fos:user:create guillaum --super-admin

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'terms_accepted' cannot be null`

Hello @Guillawme,

Please use the UserBundle DataFixtures to create your users, as per the existing example ones, since the user entity has be enhanced with extra fields that are set as required and not null.

$admin = new User();
$admin->setCreatedAt(new \DateTime());
$admin->setUpdatedAt(new \DateTime());
$admin->setUsername('administrator');
$admin->setUsernameCanonical('administrator');
$admin->setEmail('admin@domain.com');
$admin->setEmailCanonical('admin@domain.com');
$admin->setEnabled(1);
$admin->setIsSystemUser(1);
$admin->setPlainPassword('Admin1234');
$admin->setConfirmed(true);
$admin->setTermsAccepted(true);
$admin->setSuperAdmin(true);
$manager->persist($admin);

You can then load the new user with php app/console doctrine:fixtures:load command.

Let me know if you still have an issue with this (for v2.8.11).

Hello @Guillawme,

Regardless, I have lifted the not null constraint from the fields that where causing the issue so you can now create your user as expected with

php app/console fos:user:create guillaum --super-admin