How do you choose to control the display of different roles in view?

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.