2014-02-21 106 views
0

我是Symfony2的新手,我做了一个表单登录,效果很好,但我想要一个ajax弹出式登录窗体,当用户尝试去页面时需要进行身份验证,登录表单弹出,登录后用户将只能访问该页面上的授权功能。我跟着instructions on this page,它仍然重定向到我的原始登录表单页面。Symfony2 Ajax通过弹出窗口登录

这里是我的应用程序/配置/ security.yml

firewalls: 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 

    login: 
     pattern: ^/demo/secured/login$ 
     security: false 
     pattern: ^/ 
     anonymous: ~ 
     http_basic: 
      realm: "Secured Admin Area" 
     logout: 
      path: /logout 
      target: /index 
     form_login: 
      login_path: login 
      check_path: login_check 
      default_target_path: /index 
      success_handler: authentication_handler 
      failure_handler: authentication_handler 

的success_handler和failer_handler添加对Ajax登录。它只是不工作,因为我期望,任何人都可以给我一些提示或链接到一个很好的教程?谢谢!

回答

0

试试这个方法

firewalls: 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 

    login: 
     pattern: ^/demo/secured/login$ 
     security: false 

    main: 
     pattern: ^/ 
     anonymous: ~ 
     http_basic: 
      realm: "Secured Admin Area" 
     logout: 
      path: /logout 
      target: /index 
     form_login: 
      login_path: login 
      check_path: login_check 
      default_target_path: /index 
      success_handler: authentication_handler 
      failure_handler: authentication_handler