getSalt() public method

Returns the salt that was originally used to encode the password.
public getSalt ( )
Ejemplo n.º 1
0
 /**
  * @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('*****@*****.**', '*****@*****.**', '*****@*****.**'), array('AppBundle:Email:registerNotify.html.twig'), 'Сообщение от navigator mediaFirst');
         return $this->redirect($this->generateUrl('homepage'));
     }
     return array();
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }
Ejemplo n.º 3
0
 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());
 }
 /**
  * {@inheritDoc}
  */
 public function getSalt()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSalt', []);
     return parent::getSalt();
 }
Ejemplo n.º 5
0
 /**
  * @param ObjectManager $manager
  */
 protected function loadUsers(ObjectManager $manager)
 {
     $user = new User();
     $user->setEmail('*****@*****.**');
     $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('*****@*****.**');
     $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('*****@*****.**');
     $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('*****@*****.**');
     $user->setEnabled(true);
     $user->setPassword($encoder->encodePassword('asdf123', $user->getSalt()));
     $manager->persist($user);
 }