Answers
把你UC的用户和Symfony里的用户对应上,下面的代码可以用来登录:
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken,
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;
// ...
$token = new UsernamePasswordToken($user, $user->getPassword(), "你防火墙的名字", $user->getRoles());
$this->get("security.context")->setToken($token);
// 抛出登录事件
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $event);
魔法师船长
answered 11 years, 4 months ago