Implement change password in Symfony2

后端 未结 5 1248
孤城傲影
孤城傲影 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:41

    Can't You get old password from User before binding form?

    // in action:
    $oldpassword = $user->getPassword();
    
    if ($request->getMethod() == 'POST') 
            {
                $form->bindRequest($request);
    
                if ($form->isValid()) 
                {
                    // check password here (by hashing new one)
    

提交回复
热议问题