Symfony 3:如何实现密码更新?

时间:2017-05-16 00:52:31

标签: php symfony

我正在尝试实施密码更新。因此,我要求:

1)当前密码 2)新密码 3)重复新密码

UserProfileForm中的表单构建器如下所示:

/**
* @SecurityAssert\UserPassword(
*     message = "Wrong value for your current password",
*     groups = {"updatePasswordChecked"}
* )
*/
private $oldPassword;

在用户实体中,我添加了$ oldPassword:

class ProfileController extends Controller
{
    public function detailAction(Request $request)
    {
        $user = $this->get('security.token_storage')->getToken()->getUser();

        $form = $this->createForm(UserProfileForm::class, $user);
        $form->handleRequest($request);


        if ($form->isSubmitted())
        {
            if ($form->isValid())
            {
                dump('valid');
                // do whatever is needed to update the password
            }
        }

        return $this->render('pages/profile.html.twig', array('profileForm' => $form->createView()));
    }
}

控制器,我试图更新密码:

{{1}}

使用正确的旧密码提交表单后,我收到旧密码错误的错误,系统会自动将其记录下来。

在Symfony探查器中,我可以看到正在提交正确的数据。

我做错了什么?

0 个答案:

没有答案