I have a lot of different user rights of the project, for different permissions of the user has a choice of display resources, then how to gracefully display the page.
The way to compare low (I am now), for each resource (resource) before the display, to determine whether allowed, there is no elegant method?
Pseudo code eg:
If Acl.isallowed (Currentuser,targetresource1)
Show TargetResource1
End
If Acl.isallowed (CURRENTUSER,TARGETRESOURCE2)
Show TargetResource2
End
If Acl.isallowed (CURRENTUSER,TARGETRESOURCE3)
Show TargetResource3
End
。。。
Reply content:
I have a lot of different user rights of the project, for different permissions of the user has a choice of display resources, then how to gracefully display the page.
The way to compare low (I am now), for each resource (resource) before the display, to determine whether allowed, there is no elegant method?
Pseudo code eg:
If Acl.isallowed (Currentuser,targetresource1)
Show TargetResource1
End
If Acl.isallowed (CURRENTUSER,TARGETRESOURCE2)
Show TargetResource2
End
If Acl.isallowed (CURRENTUSER,TARGETRESOURCE3)
Show TargetResource3
End
。。。
Set different roles/users ' access control settings to different resources in the database
Get a list of resource access based on the role they belong to after the user logs on
Display UI assembly pages in a list of accessible resources combined with pages
RBAC Rights Management Try
The code refactoring is not better.
ruby
%w(targetResource1 targetResource2 targetResource3).each do |target| show target if acl.isAllowed(currentUser, target)end