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

Feature request: if_true beside if_attribute and if_permitted_to #179

Open
nagyt234 opened this issue Apr 17, 2013 · 2 comments
Open

Feature request: if_true beside if_attribute and if_permitted_to #179

nagyt234 opened this issue Apr 17, 2013 · 2 comments

Comments

@nagyt234
Copy link

It would be a nice feature to have if_true in a #has_permission_on block, to check conditions of dynamic parameters that have to be met for the user to meet the privileges in this block. This would be especially useful on new, where no attributes are known yet.

E.g:

 role :login do
    includes :guest

    # -- Document

    has_permission_on [:documents], :to => [:manage, :view] do
      if_attribute :folder_id => is_in { Folder.get_folder_ids_permitted(
        user, [:root, :admin, :update]) }
    end
    has_permission_on [:documents], :to => :view do
      if_attribute :folder_id => is_in { Folder.get_folder_ids_permitted(
        user, :read) }
    end
    has_permission_on [:documents], :to => :new do
      if_true {Folder.has_roles_anywhere?(user, [:root, :admin, :update]) }
    end
  end
@stevehodges
Copy link

It seems that this could solve my use case as well. I figure that I already have access to user, and should thusly be able to access a boolean on said user.

My use case is checking a boolean on the actual user:
if_true user.configurable_setting_boolean?

or
if_true user.company.configiruable_setting_boolean?

@sneakernets
Copy link

If this can be done, It'd make the ability for me to create a new user through rails much easier.

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

3 participants