Implement change password in Symfony2

后端 未结 5 1244
孤城傲影
孤城傲影 2020-12-07 17:45

What is the best way to implement change password functionality in Symfony2? Right now I\'m using this:

$builder->add(\'password\', \'repeated\', array(
         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-07 18:38

    You have to either create another model with two fields:

    • one for the current password;
    • and the other for the new one.

    Or add a non-persisted property to your user model like the FOSUserBundle does (see the plainPassword property).

    So once you checked both current and new password are valid, you encode the new password and replace the old one with it.

提交回复
热议问题