-1

They are at the first experiences with laravel 5 and backpack. I installed the backpack permission manager and I have a questions:

I created permissions / roles and created two users.

  1. in my sidebar_content.blade.php I use conditions correctly
    @role('Admin')
    <!-- Users, Roles, Permissions -->
    <li class="nav-item nav-dropdown">
        <a class="nav-link nav-dropdown-toggle" href="#"><i class="nav-icon la la-users"></i> Authentication</a>
        <ul class="nav-dropdown-items">
            <li class="nav-item"><a class="nav-link" href="{{ backpack_url('user') }}"><i class="nav-icon la la-user"></i> <span>Users</span></a></li>
            <li class="nav-item"><a class="nav-link" href="{{ backpack_url('role') }}"><i class="nav-icon la la-id-badge"></i> <span>Roles</span></a></li>
            <li class="nav-item"><a class="nav-link" href="{{ backpack_url('permission') }}"><i class="nav-icon la la-key"></i> <span>Permissions</span></a></li>
        </ul>
    </li>
    <li class="...
    <li class="...
    @role('Magazzino1')
    <li class="...
    @endrole
    @role('Magazzino2')
    <li class="...
    @endrole

but if i know the example routing / admin / user / create I access the page (also for Edit / delete etc ...)

How can I allow access only if the user in use is with the "Admin" role? Thank you

Mattew
  • 1

1 Answers1

1

Backpack uses backpack auth, while @role, @can etc directives by default use the laravel auth.

You can accomplish the same by using backpack_user()->hasRole('your_role') or by telling laravel to use the backpack auth instead of the default one.

Please read the PermissionManager package README and you have an example there on how to to achieve the second scenario if that's your desire. https://github.com/Laravel-Backpack/PermissionManager (it's the 7 point on the README).

Cheers

Pedro X
  • 849
  • 5
  • 13