dsh102123 2018-04-05 16:31
浏览 98
已采纳

多个控制器中的Symfony 3登录表单

I followed this tutorial on how to build a login form in Symfony 3 and everything works fine.

However I'd like to use the same login form on multiple pages ("/" and "/login"). Unfortunately I can always get only one of these pages working based on how I configure the "login_path" and "check_path" in security.yaml.

So it's either

form_login:
                  login_path: login
                  check_path: login

or

form_login:
                  login_path: /
                  check_path: /

I've tried to add another firewall specifically for the login page to use both at once, but without success, my form on /login would then seem to submit and would redirect to default_target_path, but the user wouldn't be logged in. I've also tried to set the 'action' variable in the function createForm in controller to make the login form submit to /login even on the index page, but that didn't work either.

Any ideas on how to solve this issue ?

  • 写回答

2条回答 默认 最新

  • dsm0688 2018-04-05 18:13
    关注

    Have you tried creating a second entry with a different name? I'm not sure it will work, but technically different providers with different names are allowed. And there's no requirement they actually have different providers or different implementations.

    security:
        # ...
    
        firewalls:
            main:
                # ...
                form_login:
                    login_path: login
                    check_path: login
            alternative
                # ...
                form_login:
                    login_path: /
                    check_path: /
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog