Created
January 2, 2015 21:30
-
-
Save danbower/3dd39392f8b9ab15c0c1 to your computer and use it in GitHub Desktop.
Manual login for symfony
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
public function manualLoginAction() | |
{ | |
$user = $this->getDoctrine()->getRepository('UserBundle:User')->find(1); | |
$token = new UsernamePasswordToken($user, $user->getPassword(), 'admin_area', $user->getRoles()); | |
$this->get('security.context')->setToken($token); | |
$request = $this->get('request'); | |
$event = new InteractiveLoginEvent($request, $token); | |
$this->get("event_dispatcher")->dispatch('security.interactive_login', $event); | |
echo 'Logged in'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment