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


PHP User::setSalt方法代码示例

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


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

示例1: createAction

 public function createAction($format)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $user = new User();
         $params = array();
         $content = $this->get("request")->getContent();
         if (!empty($content)) {
             $params = json_decode($content, true);
             $user->setConfirmationToken($params['confirmationToken']);
             $user->setCredentialsExpireAt($params['credentialsExpireAt']);
             $user->setCredentialsExpired($params['credentialsExpired']);
             $user->setEmail($params['email']);
             $user->setEmailCanonical($params['emailCanonical']);
             $user->setEnabled($params['enabled']);
             $user->setExpired($params['expired']);
             $user->setExpiresAt($params['expiresAt']);
             $user->setLastLogin($params['lastLogin']);
             $user->setLocked($params['locked']);
             $user->setPassword($params['password']);
             $user->setPasswordRequestedAt($params['passwordRequestedAt']);
             $user->setRoles($params['roles']);
             $user->setSalt($params['salt']);
             $user->setUsername($params['username']);
             $user->setUsernameCanonical($params['usernameCanonical']);
         }
         $em->persist($user);
         $em->flush();
         return $this->formatResponse("ok", $format);
     } catch (Exception $ex) {
         return $this->formatResponse("error", $format);
     }
 }
开发者ID:dowrow,项目名称:Symfony-REST,代码行数:33,代码来源:UserController.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: 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

示例4: manageCredentials

 public function manageCredentials(User $user)
 {
     $salt = $this->saltGenerator->nextBytes(15);
     $user->setSalt(md5($salt));
     $encodedPassword = $this->encoder->encodePassword($user, $user->getPassword());
     $user->setPassword($encodedPassword);
     return $user;
 }
开发者ID:saro0h,项目名称:sf2c2,代码行数:8,代码来源:AppCredentialsHandler.php

示例5: register

 public function register(User $user)
 {
     $user->setSalt(md5(time()));
     $password = $this->securityEncoderFactory->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt());
     $user->setPassword($password);
     $this->em->persist($user);
     $this->em->flush();
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'app', $user->getRoles());
     $this->securityContext->setToken($token);
 }
开发者ID:AeonRush,项目名称:demoblog,代码行数:10,代码来源:UserManager.php

示例6: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('admin@gmail.com');
     $userAdmin->setSalt('abc');
     $userAdmin->setPassword('test');
     $manager->persist($userAdmin);
     $manager->flush();
     $this->addReference('user-admin', $userAdmin);
 }
开发者ID:josecollazzi,项目名称:bigblue,代码行数:14,代码来源:LoadUserData.php

示例7: register

 public function register(User $user, $flush = true)
 {
     $user->addPermission('ROLE_PLAYER');
     $user->setSalt(sha1($this->saltGenerator->nextBytes(128)));
     $user->setPassword($this->passwordEncoder->encodePassword($user, $user->getPassword()));
     if (!$user->getCreditsBalance()) {
         $user->credit(500);
     }
     $this->entityManager->persist($user);
     if ($flush) {
         $this->entityManager->flush();
     }
 }
开发者ID:barachenadia,项目名称:Formation-Symfony-Hugo-Hamon,代码行数:13,代码来源:RegistrationService.php

示例8: load

 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param Doctrine\Common\Persistence\ObjectManager $manager
  */
 function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('test');
     $user->setSalt(md5(\uniqid()));
     $encoder = $this->getEncoder($user);
     $password = $encoder->encodePassword('123', $user->getSalt());
     $user->setPassword($password);
     $user->setCreatedAt(new \DateTime());
     $user->setUpdatedAt(new \DateTime());
     $manager->persist($user);
     $manager->flush();
 }
开发者ID:raul-scalable,项目名称:DroneSf,代码行数:18,代码来源:LoadUserData.php

示例9: load

 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setSalt(md5(uniqid()));
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($userAdmin);
     $userAdmin->setPassword($encoder->encodePassword('secret', $userAdmin->getSalt()));
     $defaultEmail = $this->container->getParameter('default_email');
     $userAdmin->setEmail($defaultEmail);
     $userAdmin->setIsActive(true);
     $manager->persist($userAdmin);
     $manager->flush();
     $this->addReference("admin-user", $userAdmin);
 }
开发者ID:supercoda,项目名称:my-project-skeleton,代码行数:14,代码来源:LoadUserData.php

示例10: register

 public function register(User $user, $flush = true)
 {
     $user->setSalt(sha1($this->randomizer->nextBytes(128)));
     $encoded = $this->encoder->encodePassword($user, $user->getPassword());
     $user->setPassword($encoded);
     $this->entityManager->persist($user);
     if ($flush) {
         $this->entityManager->flush();
     }
     if ($this->tokenStorage) {
         $token = new UsernamePasswordToken($user, $user->getPassword(), 'users', $user->getRoles());
         $this->tokenStorage->setToken($token);
     }
 }
开发者ID:alde7,项目名称:insightTest,代码行数:14,代码来源:UserManager.php

示例11: loadUsers

 private function loadUsers(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('admin@localhost.local');
     $userAdmin->setSalt(md5(time()));
     $passwordEnClaro = 'password';
     $encoder = $this->container->get('security.encoder_factory')->getEncoder($userAdmin);
     $passwordCodificado = $encoder->encodePassword($passwordEnClaro, $userAdmin->getSalt());
     $userAdmin->setPassword($passwordCodificado);
     $userAdmin->setRoles(array('ROLE_ADMIN'));
     $manager->persist($userAdmin);
     $manager->flush();
 }
开发者ID:alegperea,项目名称:CMS,代码行数:14,代码来源:LoadFixtures.php

示例12: postUsersAction

 public function postUsersAction(Request $request)
 {
     $entity = new User();
     $entity->setUsername($request->query->get('username'));
     $entity->setUsernameCanonical(strtolower($request->query->get('username')));
     $entity->setEmail($request->query->get('email'));
     $entity->setEmailCanonical(strtolower($request->query->get('email')));
     $entity->setEnabled(true);
     $entity->setSalt("salt");
     $entity->setPassword($request->query->get('password'));
     $entity->setLocked(false);
     $entity->setExpired(false);
     $entity->setCredentialsExpireAt(new \DateTime('2000-01-01'));
     $entity->setCredentialsExpired(false);
     $em = $this->getDoctrine()->getManager();
     $em->persist($entity);
     $em->flush();
 }
开发者ID:imolinuevo,项目名称:ECP2PHP,代码行数:18,代码来源:UserFOSController.php

示例13: load

 public function load(ObjectManager $manager)
 {
     // Les noms d'utilisateurs à créer
     $listNames = array('Alexandre', 'Marine', 'Anna');
     foreach ($listNames as $name) {
         // On crée l'utilisateur
         $user = new User();
         // Le nom d'utilisateur et le mot de passe sont identiques
         $user->setUsername($name);
         $user->setPassword($name);
         // On ne se sert pas du sel pour l'instant
         $user->setSalt('');
         // On définit uniquement le role ROLE_USER qui est le role de base
         $user->setRoles(array('ROLE_USER'));
         // On le persiste
         $manager->persist($user);
     }
     // On déclenche l'enregistrement
     $manager->flush();
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:20,代码来源:LoadUser.php

示例14: setUserAction

 /**
  * @Route("/setuser", name="setUser")
  * @Template()
  */
 public function setUserAction()
 {
     $em = $this->getDoctrine()->getManager();
     for ($i = 1; $i <= 128; $i++) {
         if ($i < 10) {
             $pass = 'BLS2014MS000';
             $login = 'EJIM05780-000';
         } elseif ($i < 100) {
             $pass = 'BLS2014MS00';
             $login = 'EJIM05780-00';
         } else {
             $pass = 'BLS2014MS0';
             $login = 'EJIM05780-0';
         }
         $user = new User();
         $user->setUsername($login . $i);
         $user->setPassword($pass . $i);
         $user->setRoles('ROLE_USER');
         $user->setSalt(0);
         $em->persist($user);
         $em->flush($user);
     }
 }
开发者ID:bhdm,项目名称:Journal,代码行数:27,代码来源:AuthController.php


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