Bug related to :manage and using multiple operations in permission definition
vittorius opened this issue · 4 comments
vittorius commented
Hey there. I've spotted a couple of cases where behavior doesn't seem logical:
role :admin, proc { |user| user.admin? } do
can :manage, Merchant # can? :edit @merchant is AccessDenied, :read is OK
end
role :admin, proc { |user| user.admin? } do
can [:manage], Merchant # can? :edit @merchant is AccessDenied, :read is AccessDenied
end
role :admin, proc { |user| user.admin? } do
can [:manage, :edit], Merchant # can? :edit @merchant is AccessDenied, :read is AccessDenied
end
❓ ❓ ❓
pokonski commented
can :manage
is only a shortcut right now, it doesn't work with other attributes or inside an array, but this is worth improving so your examples can work, too :)
vittorius commented
role :admin, proc { |user| user.admin? } do
can :manage, Merchant # can? :read @merchant is OK
can :edit, Merchant # can? :edit @merchant is OK
end
vittorius commented
OK, will take into account. I'm your beta tester for today 😄
pokonski commented
Yeah, see this: https://github.com/chaps-io/access-granted/blob/master/lib/access-granted/role.rb#L71-L75
So when you provide other permissions in separate can
calls it will work :)
OK, will take into account. I'm your beta tester for today 😄
I appreciate that! :D