I have a Symfony 2.8 based project, I installed Sonata Admin Bundle and User Bundle and all is working perfectly.
Now I have another constraint that I want to add. When I user sign up, I don't want to give him access immediately to the application. Instead, the admin should be able to check the user datain before, and then grant him the access.
Example:
PersonA sign up giving his email and other data but he shouldn't be able to login. When the admin checks the data that PersonA has entered and sees that he can be allowed to access the application, he can grant him that possibility and therefor PersonA can login freely.
I'm not well accustomed to the Sonata bundles world, so I'm open to any ideas you can give me.
Thanks a lot !
Add the following in your User entity :
public function __construct()
{
parent::__construct();
$this->enabled = false;
}
If it doesn't work, add this in your Resources/config/doctrine/User.orm.xml
<!-- ... -->
<lifecycle-callbacks>
<lifecycle-callback type="prePersist" method="disable" />
</lifecycle-callbacks>
Or if it's User.orm.yml
:
lifecycleCallbacks:
prePersist: [disable]
And add the following in your User
entity :
public function disable()
{
$this->setEnabled(false);
}
Hope it works.