Symfony 2 FOS User Bundle Bootstrap modal AJAX Login

前端 未结 2 1832
北海茫月
北海茫月 2021-02-08 06:20

Has anyone already built a login form inside a Bootstrap modal with Symfony 2 and FOS User Bundle ?

Here is what I have now :

src/Webibli/UserBundle/Reso

2条回答
  •  醉梦人生
    2021-02-08 07:01

    I have found the solution. Here is what I added to my javascript,

    
    

    And here is my onAuthenticationFailure method from my handler,

    public function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
        $result = array(
            'success' => false, 
            'function' => 'onAuthenticationFailure', 
            'error' => true, 
            'message' => $this->translator->trans($exception->getMessage(), array(), 'FOSUserBundle')
        );
        $response = new Response(json_encode($result));
        $response->headers->set('Content-Type', 'application/json');
    
        return $response;
    }
    

    I think that it was the URL from my Ajax method that was wrong. Thank you for your advices.

提交回复
热议问题