Stones on the beach 830

WBOY
Release: 2016-08-08 09:24:10
Original
925 people have browsed it

1. What is permission management? Permission management is the subdivision of back-end functions and the management of different tasks for different staff.

How is RBAC implemented? Through restrictions on different controllers and different methods of controllers, Realized management.

To implement RBAC, three tables are needed, a user table, a role table, and a permission table

User table:

id ****** role_id

Role table

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

Permission table

access_id

Record all controllers or actions under the controller

2. How to control, in the parent class of the controller or the initialization of the controller Just make the judgment in the method

$role_id = $_SESSION['role_id'];

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

$access = $db->access ->findAllByPk($role['access_id']);

Get the controller or controller method to be executed according to the router class

$m = current_method();//Get the current method to be accessed

if( !in_array($m, $access)){

redirect('/index');

}

The above has introduced the seaside stone 830, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!