无需重新登录即可更改远程用户的角色 [英] Change the role of a distant user without having to relog

查看:28
本文介绍了无需重新登录即可更改远程用户的角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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 truein your security.yml :

# app/config/security.yml
security:
    always_authenticate_before_granting:  false

这篇关于无需重新登录即可更改远程用户的角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆