/** * Log in user * * @param Newscoop\Entity\User $user * @param string $providerKey * * @return UsernamePasswordToken */ public function loginUser(User $user, $providerKey) { $roles = $user->getRoles(); $token = new UsernamePasswordToken($user, null, $providerKey, $roles); $this->security->setToken($token); return $token; }