Home >Backend Development >PHP Tutorial >symfony 与 ucenter通信的问题

symfony 与 ucenter通信的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:47:02982browse

ucenter与symfony通信需要在应用文件下存在一个uc.php的文件,然后ucenter进行访问,如果可以取得这个文件的URL地址,已经如何在这个文件中进行symfony的登录等等

回复内容:

ucenter与symfony通信需要在应用文件下存在一个uc.php的文件,然后ucenter进行访问,如果可以取得这个文件的URL地址,已经如何在这个文件中进行symfony的登录等等

把你UC的用户和Symfony里的用户对应上,下面的代码可以用来登录:

<code>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);
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn