简体   繁体   English

Symfony2 - FOS UserBundle - 原始请求重定向

[英]Symfony2 - FOS UserBundle - Original request redirection

I'm using FOS UserBundle and I have defined a custom AuthenticationSuccessHandler to show a different home page depending on the roles, but I think it should be called only if the user originally requested the login page, shouldn't it ? 我正在使用FOS UserBundle,我已经定义了一个自定义AuthenticationSuccessHandler来根据角色显示不同的主页,但我认为只有在用户最初请求登录页面时才应该调用它,不应该吗?

On login success I'd like to be redirected to the original request. 登录成功后,我想重定向到原始请求。

As described in the docs , it seems to be the default behavior, but in my case, it still uses my authentication handler. 文档中所述,它似乎是默认行为,但在我的情况下,它仍然使用我的身份验证处理程序。

Can someone help me to redirect the user to his original request ? 有人可以帮助我将用户重定向到他原来的请求吗?


For the record, here is how I registered my authentication success handler service: 为了记录,这是我注册我的身份验证成功处理程序服务的方式:

services:
    security.success_handler:
        class:  Glide\SecurityBundle\[...]\AuthenticationSuccessHandler
        public: false
        arguments: ['@router', '@security.context']

Yes, the default behavior is to redirect the user to the page they originally requested. 是的,默认行为是将用户重定向到他们最初请求的页面。 However, since you are overriding the default authentication handler, you need to handle redirecting them to that page yourself. 但是,由于您要覆盖默认的身份验证处理程序,因此您需要自己处理将它们重定向到该页面。

I recommend you look at symfonys authentication handler and mimic its process for figuring out the users original request. 我建议您查看symfonys身份验证处理程序并模仿其过程以确定用户的原始请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM