Symfony2 $user->setPassword() updates password as plain text [DataFixtures + FOSUserBundle]

前端 未结 7 1772
庸人自扰
庸人自扰 2020-12-23 13:44

I\'m trying to pre-populate a database with some User objects, but when I call $user->setPassword(\'some-password\'); and then save the user object, the stri

7条回答
  •  孤城傲影
    2020-12-23 14:26

    Four lines of code and you are done. It will handle everything for you:

            $userManager = $this->container->get('fos_user.user_manager');
            $user->setPlainPassword($password);
            $userManager->updatePassword($user);  
    

提交回复
热议问题