Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model.permitted_to? does not extend :manage privilege #172

Open
anga opened this issue Feb 16, 2013 · 3 comments
Open

model.permitted_to? does not extend :manage privilege #172

anga opened this issue Feb 16, 2013 · 3 comments

Comments

@anga
Copy link

anga commented Feb 16, 2013

Hi,

Env:
ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux]
Rails 3.2.8
declarative_authorization (0.5.6)

has_permission_on [:projects, ....], to: :manage do
  if_attribute company: is_in {user.own_companies} 
end

has_permission_on :notes, to: :create do
  # Agregar notas dentro de un proyecto
  if_permitted_to :read, :notable
end

privileges do

  privilege :manage, :includes => [:index, :show, :new, :update, :destroy]
  privilege :read, :includes => [:index, :show]
  privilege :create, :includes => :new
  privilege :update, :includes => :update
  privilege :delete, :includes => :destroy
end

When I do:

note =  Note.new {notable: Project.first, ...}
note.permitted_to? :create # returns false

But if I change the permission to :projects

has_permission_on [:projects, ....], to: [:manage, :read] do
  if_attribute company: is_in {user.own_companies} 
end

rails c

note =  Note.new {notable: Project.first, ...}
note.permitted_to? :create # returns false

This is a normal behavior? Sorry if it a normal behavior, but I think should extend :manage privilege actions.

@stffn
Copy link
Owner

stffn commented Feb 17, 2013

Yes, manage should include :create in the default privilege configuration. But it seems as if you changed the default here as :manage does not include :create anymore in the privileges section. Is this the problem?

@anga
Copy link
Author

anga commented Feb 20, 2013

Sory by the delay.

Yes, that the problem.

@anga
Copy link
Author

anga commented Feb 20, 2013

Sorry, my last 2 lines of code was bad in this example, I wrote:

note =  Note.new {notable: Project.first, ...}
note.permitted_to? :create # returns false

and should be:

note =  Note.new {notable: Project.first, ...}
note.permitted_to? :create # returns true

I means, when you change :manage to [:manage, :read] in projects, the note.permitted_to? :create return true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants