From 933fd44c50f6c2834e67d1153b143b70a647e5aa Mon Sep 17 00:00:00 2001 From: Damian Date: Fri, 4 Apr 2025 12:00:51 -0600 Subject: [PATCH] Rechazar usuario que no es admin --- app/Http/Kernel.php | 1 + app/Http/Middleware/CheckAdminType.php | 25 +++++++++++++++++++++++++ routes/web.php | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/Http/Middleware/CheckAdminType.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index c34cdcf..3ba3d1b 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -63,5 +63,6 @@ class Kernel extends HttpKernel 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'adminType' => \App\Http\Middleware\CheckAdminType::class, ]; } diff --git a/app/Http/Middleware/CheckAdminType.php b/app/Http/Middleware/CheckAdminType.php new file mode 100644 index 0000000..bd92277 --- /dev/null +++ b/app/Http/Middleware/CheckAdminType.php @@ -0,0 +1,25 @@ +puesto_id == 1){ + return $next($request); + }else{ + return back(); + } + } +} diff --git a/routes/web.php b/routes/web.php index a7ec308..60ddcd8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,6 +21,8 @@ Route::get('/', function () { Auth::routes(['register'=>true,'reset'=>false]); + +Route::middleware(['auth','adminType'])->group(function(){ Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::get('/usuarios', [UsuariosController::class,'index'])->name('usuarios'); @@ -32,7 +34,7 @@ Route::post('/usuarios/store', [UsuariosController::class,'store'])->name('usuar Route::resource('trabajadores', TrabajadorController::class); Route::resource('autos', AutoController::class); - +}); /* Route::get('/usuarios', function () {