更改远程用户的角色,而无需重新登录 [英] Change the role of a distant user without having to relog
问题描述
我正在尝试使用FOSUserBundle更改用户的角色.问题是:如果用户同时登录,则他必须重新登录才能看到新角色.
I am trying to change the role of a user, using the FOSUserBundle. The problem is: if the user is logged at the same time, he has to relog to see the new role.
任何解决方案吗?
推荐答案
根据安全配置参考,有一个always_authenticate_before_granting
选项.关于这方面的信息并不多,但是我已经尝试过从数据库中加载自定义角色,并且可以解决问题.看起来每次您提出新请求时,安全组件都会重新加载角色.
According to the Security Configuration Reference, there's a always_authenticate_before_granting
option. There's not much informations about that, but I've tried it with custom roles loading from database and it does the trick. It looks like everytime you will make a new request, the security component will reload roles.
因此,如果您要确保在用户会话中刷新并重新加载角色,只需在security.yml
中将此选项设置为true
:
So if you want to make sure your roles are refreshed and reloaded in your user session just set this option to true
in your security.yml
:
# app/config/security.yml
security:
always_authenticate_before_granting: false
这篇关于更改远程用户的角色,而无需重新登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!