Symfony\Component\Security\Core\SecurityContext::setToken PHP Method

setToken() public method

Deprecation: since version 2.6, to be removed in 3.0. Use TokenStorageInterface::setToken() instead. {@inheritdoc}
public setToken ( Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token = null )
$token Symfony\Component\Security\Core\Authentication\Token\TokenInterface
    public function setToken(TokenInterface $token = null)
    {
        return $this->tokenStorage->setToken($token);
    }

Usage Example

Esempio n. 1
0
 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);
 }
All Usage Examples Of Symfony\Component\Security\Core\SecurityContext::setToken