Permissions
ezadev-admin
has built-inRBAC
permissions control module, expand the left sidebar Auth
, you can see user, permissions and roles management panel, the use of permissions control as follows:
Route permission
In the ezadev-admin 1.5
, the permissions and routes are bound together, in the edit permission page which set the current permissions can access the routing, in the HTTP method
select box to select the method of access to the path, in the HTTP path
textarea fill in the path to access.
For example, to add a permission, the permission can access the path /admin/users
in GET method, then HTTP method
select GET
, HTTP path
fill in /users
.
If you want to access all paths with the prefix /admin/users
, then the HTTP path
fill in /users*
, if the permissions include multiple access paths, wrap the line for each path.
Page permission
If you want to control the user's permissions in the page, you can refer to the following example
example1
For example, there is now a scene, here is a article module, we use create articles as an example
At first open http://localhost/admi/auth/permissions
, fill up slug field with text create-post
, and Create post
in name field, then assign this permission to some roles.
In your controller action:
example2
If you want to control the page elements of the user's display, then you need to first define permissions, such as delete-image
and view-title-column
, respectively, to control the permissions to delete pictures and display a column in grid, then assign these two permissions to roles, add following code to the grid:
Other methods
Get current user object.
Get current user id.
Get user's roles.
Get user's permissions.
User is role.
User has permission.
User don't has permission.
Is user super administrator.
Is user in one of roles.
Permission middleware
You can use permission middleware in the routes to control the routing permission
The usage of permission middleware is just as same as other middleware.
Last updated