20150403--rbac+ Home Login-02

Source: Internet
Author: User

v. Settings for Rights Management

The crud operation for permissions. 1. Add Permissions

(1) Add a permission controller and add an Add method, and copy the corresponding static page, and modify the static page inside the style picture path.

Think: What is available in the form and what data needs to be put into storage. Modify a form

(2) Create a new privilege model to add data validation and add validation rules

(3) Complete the storage of permissions

(4) In the parent permission location, remove all permissions and display them at the hierarchy level.

Open the privilege model, define the method for fetching permission data, and display it at the hierarchy level.

(5) Remove the data from the Add method inside the controller and traverse it in the corresponding static page

2. Permissions List

Add a LST method to the controller, and copy the corresponding static page, modify the path of the style and picture, the user obtains the permission data

Traverse the extracted data to a static page and add the deleted and modified connections

3. Modify Permissions

(1) Add a Save method to the privilege controller, remove the currently modified data and display it to the corresponding static page,

(2) When you perform the Modify permission, you should be careful not to regard your own child permissions as their parent permissions.

Add a method to the privilege model to remove the ID of the child permission

(3) The ID of the child permission is taken out according to the ID, if it is its own child permissions or not displayed when the static page is traversed.

Note: Change the previous Save method to update, the template file to update.html, the list of links to update, a total of three places.

(4) To complete the modification operation, when modifying the database, also to verify that the parent ID is the ID of their own child rights and their own ID,

Using a hook function, the hook function is defined inside the model and is automatically triggered when the modification is completed.

6 Hook functions:

_before_insert

_after_insert

_before_delete

_after_delete

_before_update

_after_update

The contents of the hook function:

4. Delete Permissions

20150403--rbac+ Home Login-02

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.