當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。