if_attribute 的声明性身份验证问题

发布于 2024-10-20 05:14:18 字数 469 浏览 2 评论 0原文

我的授权规则:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画骨成沙 2024-10-27 05:14:18

您可能需要将授权规则更改为:

role :tester do
  ...
  has_permission_on [:users], :to => :edit do
    if_attribute :id => is {user.id}
  end
end

我猜该用户没有名为 user 的属性,这就是您原始示例失败的原因。您必须将用户的 ID 与当前用户的 ID 进行比较。

You probably need to change your authorization rules to:

role :tester do
  ...
  has_permission_on [:users], :to => :edit do
    if_attribute :id => is {user.id}
  end
end

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文