Created
May 20, 2014 14:09
-
-
Save hghandri/0521aa71c5f18eef56f8 to your computer and use it in GitHub Desktop.
Login user on eZPublish 5 with Symfony2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userProvider = new Provider( $this->getRepository() ); | |
$user = $userProvider->loadUserByUsername( __LOGIN_USER__ ); | |
$token = new UsernamePasswordToken($user, null, "ezpublish_front", $user->getRoles()); | |
$this->get("security.context")->setToken($token); | |
//now dispatch the login event | |
$request = $this->get("request"); | |
$event = new InteractiveLoginEvent($request, $token); | |
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment