简体   繁体   English

Symfony2 HWIOAuthBundle在表单提交之前先登录

[英]Symfony2 HWIOAuthBundle do login before a form submision

I successfully installed and setup the HWIOAuthBundle. 我成功安装并设置了HWIOAuthBundle。

I'm wondering how could I show a form to unlogged user and ask him to fill the form and then do Login in with HWIOAuthBundle in the same action. 我想知道如何向未登录的用户显示表单,并请他填写表单,然后在同一操作中使用HWIOAuthBundle登录。 So the user is logged-in and the form submitted in the same action. 因此,用户已登录,并且表单在同一操作中提交。

Any guidelines on how to achieve this would be a great help 任何有关如何实现这一目标的指导方针将有很大的帮助

I've just stored the entity to session via Ajax call. 我刚刚通过Ajax调用将实体存储到会话中。 And then I followed the HWIOAuthBundle link to the facebook login. 然后,我跟随HWIOAuthBundle链接到Facebook登录名。

My code: 我的代码:

public function submitResultAjaxAction(Request $request)
{
     $entity  = new Entity();
     $form = $this->createForm(new FormType(), $entity);
     $form->bind($request);

     if ($form->isValid()) {
        $session = $this->get("session");
        $session->set('result_entity',$entity);

        $response = array("code" => 100, "success" => true);
        return new Response(json_encode($response));
     }


    $response = array("code" => 500, "success" => false);
    return new Response(json_encode($response));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM