Menu permissions issues?

Source: Internet
Author: User
The requirement is this: Each user has different permissions, first shows a one-level menu, and then the mouse moves to a level menu, display the corresponding level two menu, up to two level menu. The site is used three ifram,top, middle, left, menu in top, I think of two options, but feel there is a lack of:

The first is that when a user enters a Web site, they get a list of all of its menu permissions, forming a two-dimensional array. However, there is a drawback is that after modifying the permissions, as long as not refresh the site can not be updated immediately.

The second is that when a user enters a website, he gets his first-level menu, and then, when he clicks or slides to the first-level menu, gets his corresponding level two menu in AJAX mode. As a result, you can immediately update the level two menu permissions, the first menu is still no way to update.

There are a few questions, that is, he does not through the menu list I appear to click, but by entering the form of a URL, so there is no way to prevent, think of a response is a controller to inherit a public controller, the public controller to verify permissions.

How do you usually deal with this?

PS: When I ask this question, I have a general flow in mind, but there is little detail that is not clear. Thank you for your answer, now put my clear place in the following, hope to have encountered such problems in the classmate, can give them reference:

    1. Roles and Permissions Association table

    2. Administrator and Role Association tables

    3. The combination of the controller and the method in the permission table (example: User/index)

    4. The controller inherits a public controller, initializes the method to do the permission authentication, obtains the current URL and splits the controller and the method part User/index, obtains the permission ID

    5. Users get their own roles and see if they have this permission ID in their role;

Reply content:

The requirement is this: Each user has different permissions, first shows a one-level menu, and then the mouse moves to a level menu, display the corresponding level two menu, up to two level menu. The site is used three ifram,top, middle, left, menu in top, I think of two options, but feel there is a lack of:

The first is that when a user enters a Web site, they get a list of all of its menu permissions, forming a two-dimensional array. However, there is a drawback is that after modifying the permissions, as long as not refresh the site can not be updated immediately.

The second is that when a user enters a website, he gets his first-level menu, and then, when he clicks or slides to the first-level menu, gets his corresponding level two menu in AJAX mode. As a result, you can immediately update the level two menu permissions, the first menu is still no way to update.

There are a few questions, that is, he does not through the menu list I appear to click, but by entering the form of a URL, so there is no way to prevent, think of a response is a controller to inherit a public controller, the public controller to verify permissions.

How do you usually deal with this?

PS: When I ask this question, I have a general flow in mind, but there is little detail that is not clear. Thank you for your answer, now put my clear place in the following, hope to have encountered such problems in the classmate, can give them reference:

    1. Roles and Permissions Association table

    2. Administrator and Role Association tables

    3. The combination of the controller and the method in the permission table (example: User/index)

    4. The controller inherits a public controller, initializes the method to do the permission authentication, obtains the current URL and splits the controller and the method part User/index, obtains the permission ID

    5. Users get their own roles and see if they have this permission ID in their role;

There is a frame of reference:
Thinkcmf

Read its source code, the general idea:

Database:

1.角色表2.角色权限表3.权限表4.用户表

Users can select roles
Roles can select permissions

Permissions:

1.权限名称2.是否是父节点3.可以访问的url(这个就是控制权限的关键)

Controller:

1.登录2.主页

CONTROL permission Ideas:

1.Login的Controller首先用户需要登录,然后给一个用户的id做session。2.Index的Controller写一层父Controller,来做一系列的权限判断的操作(比较当前的url与数据库查询到的该角色对应的权限的url)

Done.

The first: All this, don't bother. Usually the change of permissions is not a super-administrator is a user with rights management rights, the former does not need to change their permissions, the latter should not have to modify their permissions (otherwise he will tune himself into a super administrator). And you modify the authority of others, that person does not know, he will come into effect on the next landing.
The second kind: Do not recommend Ajax, in fact, the above problem is clear, so this option can pass directly.

Questions about direct access: Rights Management is access Rights Management, not menu item Display/hide management, so if your controller does not implement permission detection is purely a bug. The simple approach is to check the requested action when the controller is initialized, and then perform permission detection, and the mismatch will jump directly.

Thinkphp has a ready-made backend Rights Management system module http://www.cnblogs.com/tanteng/archive/2012/11/25/2787597.html
Laravel also have landlord can refer to

  • 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.