相关疑难解决方法(0)

Symfony2 AJAX登录

我有一个例子,我试图使用Symfony2和FOSUserBundle创建一个AJAX登录.我设置我自己success_handlerfailure_handlerform_login我的security.yml文件.

这是班级:

class AjaxAuthenticationListener implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{  
    /**
     * This is called when an interactive authentication attempt succeeds. This
     * is called by authentication listeners inheriting from
     * AbstractAuthenticationListener.
     *
     * @see \Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener
     * @param Request        $request
     * @param TokenInterface $token
     * @return Response the response to return
     */
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            $result = array('success' => true);
            $response = new Response(json_encode($result));
            $response->headers->set('Content-Type', 'application/json');
            return …
Run Code Online (Sandbox Code Playgroud)

php symfony fosuserbundle

43
推荐指数
2
解决办法
3万
查看次数

标签 统计

fosuserbundle ×1

php ×1

symfony ×1