AdminLTE menu according to the user

0

I'm creating a scheduling system with Laravel and AdminLTE. The authentication method I used was not Laravel Auth or AdminLTE because I simply used a Controller that uses a method for authentication in my AD (ldap_connect and ldap_bind). Once logged in, the controller itself will search in my users table (using cpf obtained from AD) the level field that contains 1 or 2 (1 for admin and 2 for users). The intent is that the AdminLTE menu is different for admin and for users. I tried to edit the AppServiceProvider file, but it does not retrieve the session with get (), so I can not create my menu. I know that using Laravel's traditional authentication method would work fine, but in my case it's different.

Trecho da autenticação LoginController.php

$user = DB::table('users') ->where('cpf', '=', $usr) ->first();

      if (isset($user)) {
        if ($user->level == '1') {
          Session::put('admin', $user->level);
        } else {
          Session::put('admin', '2');
        }
      }else {
        Session::put('admin', '2');
      }

      $level = Session::get('admin');

      return view('welcome', compact('cpf', 'email', 'tel', 'nome', 'level'));

I tried to use Laratrust

App \ MyMenuFilter.php

Namespace App;

use JeroenNoten \ LaravelAdminLte \ Menu \ Builder; use JeroenNoten \ LaravelAdminLte \ Menu \ Filters \ FilterInterface; use Laratrust;

class MyMenuFilter implements FilterInterface {     public function transform ($ item, Builder $ builder)     {         if (isset ($ item ['permission']) & & Laratrust :: can ($ item ['permission'])             return false;         }

    return $item;
}

}

config \ adminlte.php

'menu' = > [         'SCHEDULE',         [             'text' = > 'Settings',             'icon' = > 'calendar',             'permission' = > 'configurations', // here the user does not see             'submenu' = > [                 [                     'text' = > 'Monthly',                     'url' = > '#',                     'icon_color' = > red                     'submenu' = > [                         [                             'text' = > 'Provide',                             'url' = > '#',                             'icon' = > 'calendar-plus-o',                         ],                         [                             'text' = > 'Delete',                             'url' = > '#',                             'icon' = > 'calendar-minus-o'

], [ 'text' => 'Ver', 'url' => '#', 'icon' => 'calendar-check-o', ], ], ], [ 'text' => 'Diário', 'url' => '#', 'icon_color' => 'yellow', 'submenu' => [ [ 'text' => 'Disponibilizar', 'url' => '#', 'icon' => 'calendar-plus-o', ], [ 'text' => 'Excluir', 'url' => '#', 'icon' => 'calendar-minus-o ' ], [ 'text' => 'Ver', 'url' => '#', 'icon' => 'calendar-check-o', ], ], ], ], ], 'CONFIGURAÇÕES DE USUÁRIO', [ 'text' => 'Administradores', 'url' => 'admin/settings', 'icon' => 'user-secret', 'submenu' => [ [ 'text' => 'Criar', 'url' => '#', 'icon' => 'user-plus', ], [ 'text' => 'Ver', 'url' => '#', 'icon' => 'users' ], ], ], 'AVISOS', [ 'text' => 'Agendamentos de hoje', 'icon_color' => 'red', 'label' => 2, 'label_color' => 'success', ], [ 'text' => 'Eventos de hoje', 'icon_color' => 'yellow', 'label' => 4, ], [ 'text' => 'Total de Agendamentos', 'icon_color' => 'aqua', 'label' => 2, ], ],

    
asked by anonymous 27.11.2018 / 18:49

0 answers