-1
Good morning and my first post here, I want to create a check in the Standard to check if the logged-in user belongs to the group ex: IT, DIRECTORATE, ADMINISTRATION etc. I already do the check on the route if the user is logged in using auth, I wanted a second check:
Route::group(['middlewere' => 'auth', 'prefix' => 'ti'], function(){
Route::get('/listati', 'TiController@index')->name('index');
});
I could only access this route that the user is from the IT group, my system uses adldap2 and synchronizes with AD, I even saw about doing a new middleware and checking if the user belongs to the group, but then analyzing I would have to do a 20 middleware to get if the user belongs to the given group, example:
namespace App\Http\Middleware;
use Closure;
class Verificagrupo {
public function handle($request, Closure $next)
{
if ( !auth()->check() )
return redirect()->route('login');
$setor = auth()->user()->setor;
if ( $setor != 'ti' )
return redirect->route('naoautorizado');
return $next($request);
}
}
this middleware would only be able to verify that the user and you, I would like to check not only for the IT group, but also for ADM, SAUDE, ENGINEERING etc all groups... does anyone have any ideas ? how to improve this user group check ? could give me a light indicate some library or something? and avoid having to create 20 middleware to do this group check ? I thank you in advance...
There is this library here, it is quite complete: https://spatie.be/docs/laravel-permission/v3/introduction
– Jhonny Freire
I’ll search this library friend, thank you
– dsleite360