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

symfony 与 ucenter通信的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:47:02
Original
981 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template