if_attribute 的声明性身份验证问题
我的授权规则:
role :tester do
has_permission_on [:regression_test_test_runs, :regression_test_jobs], :to => :manage
has_permission_on [:authorization_rules], :to => [:read, :manage]
has_permission_on [:users], :to => :edit do
if_attribute :user => is {user}
end
end
我的用户控制器
filter_access_to :all, :attribute_check => true
为什么我的权限仍然被拒绝?我尝试过尝试,但仍然无法获取当前用户,这是一个编辑自己的个人资料的测试人员。
my authorization rules:
role :tester do
has_permission_on [:regression_test_test_runs, :regression_test_jobs], :to => :manage
has_permission_on [:authorization_rules], :to => [:read, :manage]
has_permission_on [:users], :to => :edit do
if_attribute :user => is {user}
end
end
my users controller
filter_access_to :all, :attribute_check => true
why is it that i still get a permission denied? i've tried playing around and i still can't get the current user, which is a tester to edit his own profile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要将授权规则更改为:
我猜该用户没有名为 user 的属性,这就是您原始示例失败的原因。您必须将用户的 ID 与当前用户的 ID 进行比较。
You probably need to change your authorization rules to:
I'm guessing that user doesn't have an attribute named user, that's why your original example was failing. You'll have to compare the user's id against the current user's id instead.