Last active
June 6, 2018 18:50
-
-
Save thomsbg/48074de233573cbbf607f7b28aa456d8 to your computer and use it in GitHub Desktop.
permissions query pseudocode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
can user u perform operation o in scope s? | |
1. scopes = [s].concat(s.parents) | |
2. roles = RoleAssignment.where(user: u, scope: scopes).pluck(:role) | |
3. roles.any? { |role| ROLE_OPERATIONS_MAPPING[role].operations.include?(o) } | |
## or perhaps | |
1. scopes = [s].concat(s.parents) | |
3. roles = ROLES.select { |role| role.operations.include?(o) } | |
2. RoleAssignment.exist?(user: u, scope: scopes, role: roles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment