<bdo id='MOdYl'></bdo><ul id='MOdYl'></ul>
<tfoot id='MOdYl'></tfoot>

<small id='MOdYl'></small><noframes id='MOdYl'>

      1. <legend id='MOdYl'><style id='MOdYl'><dir id='MOdYl'><q id='MOdYl'></q></dir></style></legend>

        <i id='MOdYl'><tr id='MOdYl'><dt id='MOdYl'><q id='MOdYl'><span id='MOdYl'><b id='MOdYl'><form id='MOdYl'><ins id='MOdYl'></ins><ul id='MOdYl'></ul><sub id='MOdYl'></sub></form><legend id='MOdYl'></legend><bdo id='MOdYl'><pre id='MOdYl'><center id='MOdYl'></center></pre></bdo></b><th id='MOdYl'></th></span></q></dt></tr></i><div id='MOdYl'><tfoot id='MOdYl'></tfoot><dl id='MOdYl'><fieldset id='MOdYl'></fieldset></dl></div>

        Symfony2 $user->setPassword() 将密码更新为纯文本 [DataFixtures + F

        Symfony2 $user-gt;setPassword() updates password as plain text [DataFixtures + FOSUserBundle](Symfony2 $user-setPassword() 将密码更新为纯文本 [DataFixtures + FOSUserBundle])
              <tbody id='hOETq'></tbody>
          1. <legend id='hOETq'><style id='hOETq'><dir id='hOETq'><q id='hOETq'></q></dir></style></legend>
              • <bdo id='hOETq'></bdo><ul id='hOETq'></ul>
              • <tfoot id='hOETq'></tfoot>
                <i id='hOETq'><tr id='hOETq'><dt id='hOETq'><q id='hOETq'><span id='hOETq'><b id='hOETq'><form id='hOETq'><ins id='hOETq'></ins><ul id='hOETq'></ul><sub id='hOETq'></sub></form><legend id='hOETq'></legend><bdo id='hOETq'><pre id='hOETq'><center id='hOETq'></center></pre></bdo></b><th id='hOETq'></th></span></q></dt></tr></i><div id='hOETq'><tfoot id='hOETq'></tfoot><dl id='hOETq'><fieldset id='hOETq'></fieldset></dl></div>

                <small id='hOETq'></small><noframes id='hOETq'>

                  本文介绍了Symfony2 $user->setPassword() 将密码更新为纯文本 [DataFixtures + FOSUserBundle]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用一些用户对象预填充数据库,但是当我调用 $user->setPassword('some-password'); 然后保存用户对象时,字符串some-password"直接存储在数据库中,而不是散列+加盐密码.

                  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 string 'some-password' is stored directly in the database, instead of the hashed+salted password.

                  我的 DataFixture 类:

                  My DataFixture class:

                  // Acme/SecurityBundle/DataFixtures/ORM/LoadUserData.php
                  <?php
                  
                  namespace AcmeSecurityBundleDataFixturesORM;
                  
                  use DoctrineCommonDataFixturesFixtureInterface;
                  use DoctrineCommonPersistenceObjectManager;
                  
                  use AcmeSecurityBundleEntityUser;
                  
                  class LoadUserData implements FixtureInterface
                  {
                      public function load(ObjectManager $manager)
                      {
                          $userAdmin = new User();
                          $userAdmin->setUsername('System');
                          $userAdmin->setEmail('system@example.com');
                          $userAdmin->setPassword('test');
                  
                          $manager->persist($userAdmin);
                          $manager->flush();
                      }
                  }
                  

                  以及相关的数据库输出:

                  And the relevant database output:

                  id  username    email               salt                                password
                  1   System      system@example.com  3f92m2tqa2kg8cookg84s4sow80880g     test
                  

                  推荐答案

                  由于你使用的是 FOSUserBundle,你可以使用 UserManager 来做到这一点.我会使用这段代码(假设你设置了 $this->container):

                  Since you are using FOSUserBundle, you can use UserManager to do this. I would use this code (assuming you have $this->container set):

                  public function load(ObjectManager $manager)
                  {
                      $userManager = $this->container->get('fos_user.user_manager');
                  
                      $userAdmin = $userManager->createUser();
                  
                      $userAdmin->setUsername('System');
                      $userAdmin->setEmail('system@example.com');
                      $userAdmin->setPlainPassword('test');
                      $userAdmin->setEnabled(true);
                  
                      $userManager->updateUser($userAdmin, true);
                  }
                  

                  这篇关于Symfony2 $user->setPassword() 将密码更新为纯文本 [DataFixtures + FOSUserBundle]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)

                        <bdo id='ba2Z9'></bdo><ul id='ba2Z9'></ul>

                            <small id='ba2Z9'></small><noframes id='ba2Z9'>

                          1. <tfoot id='ba2Z9'></tfoot>
                          2. <legend id='ba2Z9'><style id='ba2Z9'><dir id='ba2Z9'><q id='ba2Z9'></q></dir></style></legend>
                            <i id='ba2Z9'><tr id='ba2Z9'><dt id='ba2Z9'><q id='ba2Z9'><span id='ba2Z9'><b id='ba2Z9'><form id='ba2Z9'><ins id='ba2Z9'></ins><ul id='ba2Z9'></ul><sub id='ba2Z9'></sub></form><legend id='ba2Z9'></legend><bdo id='ba2Z9'><pre id='ba2Z9'><center id='ba2Z9'></center></pre></bdo></b><th id='ba2Z9'></th></span></q></dt></tr></i><div id='ba2Z9'><tfoot id='ba2Z9'></tfoot><dl id='ba2Z9'><fieldset id='ba2Z9'></fieldset></dl></div>
                              <tbody id='ba2Z9'></tbody>