I have two roles in my system: users and admins. By default, when someone logs in as an user or an admin, he can modify his own password using the implemented forms of FOSUserBundle. But I'd like to forbid the users to change their own password, having to request it to the admin, so then the admin would reset it, either introducing a new one chosen by the admin, either generating a random one. I'd also like to send and a email to the user telling him that his passwd has changed and he has to use the new one from now on. But I cannot find how do that. Any help?
相关问题
- Symfony2 Set Controller in the kernelControllerEve
- Webpack Encore: cannot import local dependencies
- Render custom attribute KNP Menu
- Problems with cap deploy a symfony2 project, can
- Allow CORS on symfony 4
相关文章
- Symfony : Doctrine data fixture : how to handle la
- Symfony is linked to the wrong PHP version
- Symfony2: check whether session exists or not
- Is there a way to modify the entity mapping config
- symfony2 form choice and mongodb
- Symfony 3.1 and OneUpUploaderBundle + Blueimp = Up
- Symfony does not remove entity from collection
- Symfony: Inject object (not service) to service co
If you want an admin to change another user's password, you can use your own form:
//...
And then, in your controller:
You can prevent users from changing their password by removing the
fos_user_change_password
andfos_user_resetting
routes in yourapp/config/routing.yml
file. This way neither users nor admin will be able to change their own password through the/profile
page.Then you will need to create a secured controller action that allows admin to change passwords and send the email. In order to do that you can use FOSUserBundle
UserManager
and itssetPlainPassword()
method.Take a look at the documentation:
Symfony2 Security
FOSUserBundle User Manager
How to send an Email