Skip to content

Instantly share code, notes, and snippets.

@hghandri
Created May 20, 2014 14:09
Show Gist options
  • Save hghandri/0521aa71c5f18eef56f8 to your computer and use it in GitHub Desktop.
Save hghandri/0521aa71c5f18eef56f8 to your computer and use it in GitHub Desktop.
Login user on eZPublish 5 with Symfony2
$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