Role-based permissions control

Source: Internet
Author: User

The first thing to understand is that a table is required to record the entire project controller and method, so that when the permission detection can detect the database corresponding to the role of the controller or method permissions,

However, it is necessary to understand that in the development process, it is necessary to remove this permission, so that in the development process is the need to add a controller or method does not need to verify permissions, and then after the development of the need

Increase the Controller and method in the Permissions table.

General role-based permissions control, you need to use the following tables

1. User table 2, Permissions table, 3. Role table, 4 Permissions role Relationship table 5 user Role Relationship table

This way is the user through, the User Role Relationship table query out their role, and then through the Permissions Role Relationship table isolated, and then the permission table is the Cartesian product of the controller and method, and then

Querying the database to get a two-dimensional array of controllers and methods, and then obtain the current controller and method based on the thinkphp keyword to get whether in the two-dimensional array, you can let the current user can access

General permissions control The initialization method written on the underlying controller, such as Basecontroller,admincontroller, and then all the controllers that inherit these controllers will automatically verify their permissions, without having to write the

Role-based permissions control

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.