我通过ajax调用此脚本:
$userRepository = $this->getDoctrine( )->getRepository( 'DonePunctisBundle:User' );
$user = $userRepository->findOneByUsername( array( 'username' => $fbuser['email'] ) );
$this->_authenticateUser($user);
protected function _authenticateUser( User $user ) {
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles() );
$this->get( 'security.context' )->setToken( $token );
}
没有错误,但用户没有登录。我需要做什么?
答案 0 :(得分:0)
只需在UsernamePasswordToken中传递用户密码。
new UsernamePasswordToken($user, $user->getPassword(), 'main', $user->getRoles());