AppBundle\Entity\User::getSalt PHP Method

getSalt() public method

Returns the salt that was originally used to encode the password.
public getSalt ( )
    public function getSalt()
    {
        // See "Do you need to use a Salt?" at http://symfony.com/doc/current/cookbook/security/entity_provider.html
        // we're using bcrypt in security.yml to encode the password, so
        // the salt value is built-in and you don't have to generate one
        return;
    }

Usage Example

示例#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();
 }
All Usage Examples Of AppBundle\Entity\User::getSalt