Change default Login page in FOSUserBundle (Symfony)

江枫思渺然 提交于 2019-12-10 16:31:42

问题


I think that both the question and the answer here shouldn't be very complicated.

I have installed and configured the FOSUserBundle to use in a project with Symfony2.

What I need to know is where I tell the Security which page it has to redirect the user when they try to access to a forbidden url.

By default it is /login. But I'd like to change it to a more general /main.

Thanks in advance


回答1:


It's not done by FOSUserBundle, but the Security system in Symfony2. You need to set the following in security.yml:

firewalls:
    main:
        form_login:
            default_target_path: /path/to/redirect/to

EDIT:

Sorry, misread the question. Change login_path to /admin like so:

firewalls:
    main:
        form_login:
            login_path: /admin

This will redirect you to the /admin page - make sure the path works and isn't protected by the firewall. More info here.




回答2:


Ok

I got it!

It was more like:

        main:
        form_login:
            login_path: /path/to/redirect/to

Thanks again



来源:https://stackoverflow.com/questions/11819547/change-default-login-page-in-fosuserbundle-symfony

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!