当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getSalt方法代码示例

本文整理汇总了PHP中AppBundle\Entity\User::getSalt方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getSalt方法的具体用法?PHP User::getSalt怎么用?PHP User::getSalt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::getSalt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerAction

 /**
  * @Route("/register", name="register")
  * @Template()
  */
 public function registerAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $manager = $this->getDoctrine()->getManager();
         $user = new User();
         $user->setUsername($request->request->get('username'));
         $user->setSalt(md5(time()));
         $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
         $password = $encoder->encodePassword($request->request->get('password'), $user->getSalt());
         $user->setPassword($password);
         $user->setRoles('ROLE_UNCONFIRMED');
         $user->setLastName($request->request->get('lastName'));
         $user->setFirstName($request->request->get('firstName'));
         $user->setSurName('');
         $user->setPhone($request->request->get('phone'));
         $user->setCompany($request->request->get('companyTitle'));
         $manager->persist($user);
         $manager->flush($user);
         $manager->refresh($user);
         $session = new Session();
         $session->getFlashBag()->add('success', 'Ваша заявка принята. Пожалуйста, ожидайте подтверждения регистрации на указанный электронный адрес');
         @$this->get('email.service')->send(array($user->getUsername()), array('AppBundle:Email:registerNotifyUser.html.twig'), 'Сообщение от navigator mediaFirst');
         @$this->get('email.service')->send(array('tulupov.m@gmail.com', 'ryabova.t@mediafirst.ru', 'kravtsova.m@mediafirst.ru'), array('AppBundle:Email:registerNotify.html.twig'), 'Сообщение от navigator mediaFirst');
         return $this->redirect($this->generateUrl('homepage'));
     }
     return array();
 }
开发者ID:Quiss,项目名称:Oon,代码行数:31,代码来源:AuthController.php

示例2: loginAction

 /**
  * @Route("/admin-login", name="admin-login")
  * @Template()
  */
 public function loginAction()
 {
     // создание пользователя
     $manager = $this->getDoctrine()->getManager();
     $user = new User();
     $user->setUsername('admin');
     $user->setSalt(md5(time()));
     $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
     $password = $encoder->encodePassword('admin', $user->getSalt());
     $user->setPassword($password);
     $user->setRoles('ROLE_OPERATOR');
     $user->setLastName('admin');
     $user->setFirstName('admin');
     $user->setSurName('admin');
     $user->setPhone('+79161111111');
     //
     $manager->persist($user);
     $manager->flush($user);
     if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
         $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
     } else {
         $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
     }
     $pages = $this->getDoctrine()->getRepository('AppBundle:Page')->findAll();
     return array('error' => $error, 'pages' => $pages);
 }
开发者ID:Quiss,项目名称:Oon,代码行数:30,代码来源:AuthController.php

示例3: testConstruct

 public function testConstruct()
 {
     $user = new User();
     $user2 = new User();
     $this->assertInternalType('string', $user->getSalt());
     $this->assertNotEmpty($user->getSalt());
     $this->assertFalse($user->getSalt() == $user2->getSalt());
     $this->assertTrue($user->isActive());
     $this->assertInternalType('array', $user->getRoles());
 }
开发者ID:Pamoi,项目名称:photo-gallery-api,代码行数:10,代码来源:UserTest.php

示例4: getSalt

 /**
  * {@inheritDoc}
  */
 public function getSalt()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSalt', []);
     return parent::getSalt();
 }
开发者ID:reathh,项目名称:MotikarqSystem,代码行数:8,代码来源:__CG__AppBundleEntityUser.php

示例5: loadUsers

 /**
  * @param ObjectManager $manager
  */
 protected function loadUsers(ObjectManager $manager)
 {
     $user = new User();
     $user->setEmail('learner@example.com');
     $user->setFirstName('Kalle');
     $user->setLastName('Anka');
     $user->setEnabled(true);
     $user->addRole('ROLE_COMPLETE_USER');
     $user->setWantToLearn(true);
     $user->setAge(35);
     $user->setAbout('Sportintresserad man med 3 barn');
     $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]);
     $user->setFrom('SY');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/1.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-learner', $user);
     $user = new User();
     $user->setEmail('fluentspeaker@example.com');
     $user->setFirstName('Kal p');
     $user->setLastName('Dal');
     $user->setEnabled(true);
     $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']);
     $user->setWantToLearn(false);
     $user->setAge(40);
     $user->setAbout('Sportintresserad lärare');
     $user->setCategories([$this->getReference('category-0'), $this->getReference('category-1')]);
     $user->setFrom('SE');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/2.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-fluentspeaker', $user);
     $user = new User();
     $user->setEmail('glenn@example.com');
     $user->setFirstName('Glenn');
     $user->setLastName('GBG');
     $user->setEnabled(true);
     $user->setRoles(['ROLE_COMPLETE_USER', 'ROLE_ADMIN']);
     $user->setWantToLearn(false);
     $user->setAge(20);
     $user->setAbout('Göteborgare');
     $user->setCategories([$this->getReference('category-1'), $this->getReference('category-2')]);
     $user->setFrom('SE');
     $user->setGender('M');
     $user->setProfilePicture('http://api.randomuser.me/portraits/thumb/men/3.jpg');
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
     $this->addReference('user-glenn', $user);
     $user = new User();
     $user->setEmail('incomplete@example.com');
     $user->setEnabled(true);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
 }
开发者ID:EmmaHammar,项目名称:Kompisbyran,代码行数:62,代码来源:LoadData.php


注:本文中的AppBundle\Entity\User::getSalt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。