Stone on the beach 830

Source: Internet
Author: User
: This article mainly introduces stone 830 on the beach. if you are interested in PHP tutorials, please refer to it. 1. what is permission management? permission management refers to the subdivision of background functions and the management of Jobs divided by different employees

How RBAC is implemented is managed by limiting the methods of different controllers and controllers.

To implement RBAC, three tables, one user table, one role table, and one permission table are required.

User table:

Id ****** role_id

Role table

Role_id ****** access_ids (record all accessible permission IDs)

Permission table

Access_id

Records the actions of all controllers or controllers.

2. how to control it? just make a judgment in the parent class of the controller or the initialization method of the controller.

$ Role_id = $ _ SESSION ['role _ id'];

$ Role = $ db-> role-> findByPk ($ role_id );

$ Access = $ db-> access-> findAllByPk ($ role ['Access _ id']);

Obtain the controller or controller method to be executed based on the vro class

$ M = current_method (); // Obtain the method to be accessed

If (! In_array ($ m, $ access )){

Redirect ('/index ');

}

The above introduces the stone 830 on the beach, including the content, hope to be helpful to friends who are interested in PHP tutorials.

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.