Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Check Permission From Roles
  • Hi everyone,

    I need an example to understand how work Roles-User-Permission relation.

    I want to know how check and restrict access for admin user.

    I have a superadmin who have CRUD permission over ACL area; and a admin user who will have permission for CRUD over Pages area.

    I have this next directory tree:
    controller
       admin
           acl
           pages

    view
        admin
            acl
                 (CRUD views)
            pages
                 (CRUD views)

    Anyone can show how do it that?

    Thank so much
  • Harro VertonHarro Verton
    Accepted Answer
    You need to know how to check it, or how to store it?


  • Hi Harro Again,

    I have read all the documents, but I do not understand how to use it to restrict access and grant access to users.
    For example, I have:

    User: admin
    Function: administrator
    Actions: index, view, edit, create.

    And I have two areas:

    Admin (with ACL function)
    Pages (For blog pages.)

    I also have a superadmin, who can do everything and work it fine. But the administrator only can use and view the Pages options, includes into the menu.

    How can I do to restrict user admin.

    I have kown right of how to check the login, groups, functions, but without permissions and less to restrict with this data.
  • You need to populate the database first.

    Assuming "administrator" is a Role, you need to create this role, and assign the user "admin" to it. Then you need to create the Permission records for that role. Your app will direct how to do that. Normally, you create a Permission for a specific function (for example "usermanagement"), and add actions to the Permission for all actions you can do, like "create user", "edit" user", "list users", "reset password", "change email", "delete user", etc. When done, you assign the Permission record to the created Role. No need to assign actions at this point, as an "administrator" will have all permissions.

    When done, you can check the permission in your code:

    if ( ! Auth::has_access('usermanagement.list_users'))
    {
        // redirect the user away with an error message
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion