Symfony2 AJAX Login

前端 未结 7 2732
谎友^
谎友^ 2020-11-28 01:42

I have an example where I am trying to create an AJAX login using Symfony2 and FOSUserBundle. I am setting my own success_handler and failure_handler

7条回答
  •  醉酒成梦
    2020-11-28 02:30

    If you want the FOS UserBundle form error support, you must use:

    $request->getSession()->set(SecurityContext::AUTHENTICATION_ERROR, $exception);
    

    instead of:

    $request->getSession()->setFlash('error', $exception->getMessage());
    

    In the first answer.

    (of course remember about the header: use Symfony\Component\Security\Core\SecurityContext;)

提交回复
热议问题