protected function authenticateUser(UserInterface $user, $reAuthenticate = false) { $providerKey = $this->container->getParameter('fos_user.provider_key'); $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles()); if (true === $reAuthenticate) { $token->setAuthenticated(false); } $this->container->get('security.context')->setToken($token); }