Symfony2 上的动态 default_target_path
我正在使用 Symfony2 和 FOSUserbundle 开发一个应用程序。
当用户登录系统时,我想将他们重定向到 /user/username,显然每个用户的用户名都会改变。
Security.yml 的选项之一是default_target_path。是否可以将 default_target_path 设置为动态路径,或者我需要覆盖负责登录的 FOSUB 类。
I'm developing an application with Symfony2 and FOSUserbundle.
When a user logs in on the system I want to redirect them to /user/username, were username obviously change with every user.
One option of Security.yml is default_target_path. Is it possible to set default_target_path to a dynamic path or I need to override the class of FOSUB on charge of login.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
覆盖 SecuredController 和 模板伴侣。
当用户登录时在控制器中,创建变量并将其传递给您的模板伙伴
Overwrite SecuredController and Templemate.
In controller when user is login, create variable and pass it to your templemate
上面的答案是错误的,您必须注册一个服务作为实现 AuthenticationSuccessHandlerInterface 的防火墙的 success_handler (您可以模仿 DefaultAuthenticationSuccessHandler),
这里的正确答案: Symfony2 扩展 DefaultAuthenticationSuccessHandler
The answer above is wrong, you have to register a service as the success_handler for your firewall implementing AuthenticationSuccessHandlerInterface (you can mimic DefaultAuthenticationSuccessHandler)
right answer here: Symfony2 extending DefaultAuthenticationSuccessHandler