duandong7980 2013-02-28 11:51
浏览 24

symfony2中的FOS_USER和changepassword(如果php不是5.3.6?)

sooo basically Im trying to change the password of my users using FOS_USER and symphony.

the code goes as follows (it's the same code as the one on ChangePasswordAction in the FOS_User symphony bundle but the response has been changed to use AJAX

   public function changePasswordAction(Request $request) {
   // $form = $this->createForm(new ChangePasswordFormType('Bandness\BandeeBundle\Entity\Bandee'), $this->getUser());

    $user = $this->getUser();

    $dispatcher = $this->container->get('event_dispatcher');

    $event = new GetResponseUserEvent($user, $request);
    $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_INITIALIZE, $event);

    if (null !== $event->getResponse()) {
        return $event->getResponse();
    }

    $formFactory = $this->container->get('fos_user.change_password.form.factory');

    $form = $formFactory->createForm();
    $form->setData($user);

    if ($request->isMethod('POST')) {
        $form->bind($request);
        if ($form->isValid()) { 
            /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
            $userManager = $this->container->get('fos_user.user_manager');

            $event = new FormEvent($form, $request);
            $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_SUCCESS, $event);

            $userManager->updateUser($user);

            $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_COMPLETED, new FilterUserResponseEvent($user, $request, new Response()));

            return new JsonResponse($this->get('translator')->trans('Bandee.config.changepass.success'),200);
        }
        else return new JsonResponse($this->getTranslatedErrors($form), 422);
    }

the thing is that this doesn't seem to be working. when in an apache2 with php 5.3.6 it works perfectly, however on other machines it just doesnt work. the reply it normally gives is "not a valid number" , which doesn't make sense because it shouldn't check a number at all...

i feel there is a bug in FOS_User and some versions of PHP it's not working on PHP Version 5.4.4 neither on 5.3.10

any suggestions?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单