|
|
@ -15,7 +15,16 @@ class AdminMiddleware |
|
|
|
*/ |
|
|
|
public function handle(Request $request, Closure $next): Response |
|
|
|
{ |
|
|
|
if (!auth()->check() || auth()->user()->tipo->nombre !== 'Administrador') { |
|
|
|
if (auth()->check()) { |
|
|
|
\Log::info('AdminMiddleware', [ |
|
|
|
'user_id' => auth()->user()->id, |
|
|
|
'email' => auth()->user()->email, |
|
|
|
'tipos_id' => auth()->user()->tipos_id |
|
|
|
]); |
|
|
|
} else { |
|
|
|
\Log::info('AdminMiddleware', ['user' => null]); |
|
|
|
} |
|
|
|
if (!auth()->check() || auth()->user()->tipos_id != 1) { |
|
|
|
return redirect('/')->with('error', 'No tienes permisos para acceder a esta página.'); |
|
|
|
} |
|
|
|
|
|
|
|