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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵