简体   繁体   English

Symfony FOSUserBundle坚持sf_redirect

[英]Symfony FOSUserBundle Persist sf_redirect

I am trying to redirect the user to an activation page from an external source. 我正在尝试将用户从外部源重定向到激活页面。

Essentially they click our CTA and it requests a service, then it works as follows: 基本上他们点击我们的CTA并请求服务,然后它的工作原理如下:

  1. Unauthenticated User Clicks CTA 未经身份验证的用户单击CTA
  2. (Not Logged In) User gets blocked by the firewall, redirects to /login (未登录)用户被防火墙阻止,重定向到/ login
  3. If the user logs in they get redirected to the correct route that was requested and everything works as expected. 如果用户登录,则会将其重定向到请求的正确路由,并且一切都按预期工作。

Now my issue lies in when the unauthenticated user does not login, and rather creates an account, FOSUserBundle automatically unsets the sf_redirect cookie which in turn breaks the functionality that exists. 现在我的问题在于未经身份验证的用户未登录,而是创建帐户时,FOSUserBundle会自动取消设置sf_redirect cookie,从而破坏现有的功能。

I would like to know if there is a way to persist the sf_redirect request onto the registerAction and once the user completes registration redirect to the correct place. 我想知道是否有办法将sf_redirect请求持久化到registerAction,并且一旦用户完成注册重定向到正确的位置。

I know one way to do this would be to hook into the loginController for the FOS User Bundle and persist the requested route into another cookie parameter and lookup weather or not that parameter is set and redirect ( or not ) I was just wondering if there was a cleaner / better way of doing this ?. 我知道这样做的一种方法是挂钩到FOS用户包的loginController并将请求的路由保存到另一个cookie参数并查找天气或不设置该参数并重定向(或不)我只是想知道是否有这样做更清洁/更好的方法?

I Managed to resolve this by hooking into the the events and setting a cookie, I then checked that cookie once the login || 我管理通过挂钩事件并设置cookie来解决这个问题,然后我在登录后检查了那个cookie Register complete event was fired and I redirect the user to the specified URL if it is in an array of URLS I permit through the firewall. 注册完成事件被触发,如果它位于我允许通过防火墙的URLS数组中,我将用户重定向到指定的URL。

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

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