Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function autoLoginAction($userData)
- {
- $em = $this->getDoctrine()->getManager();
- $user = $em->getRepository('HfAppBundle:User')->findOneBy(array('email' => $userData['email']));
- $userCreated = 0;
- if (empty($user)) {
- $kernel = $this->get('kernel');
- $app = new Application($kernel);
- $userName = $userData['email'];
- $email = $userData['email'];
- $password = $userData['password'];
- $input = new StringInput("fos:user:create $userName $email $password");
- $output = new StreamOutput(fopen('php://temp', 'w'));
- $result = $app->doRun($input, $output);
- rewind($output->getStream());
- $commandResponse = stream_get_contents($output->getStream());
- if (!$result) {
- $user = $em->getRepository('HfAppBundle:User')->findOneBy(array('email' => $email));
- } else {
- //Unable to create user.
- echo $commandResponse;
- //return 0
- }
- }
- if (!empty($user)) {
- $user = $em->getRepository('HfAppBundle:User')->findOneBy(array('id' => $id));
- $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
- $this->get('session')->set('_security_main', serialize($token));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement