diff --git a/app/Http/Controllers/AttendanceController.php b/app/Http/Controllers/AttendanceController.php index 4e6ea05..62b24ad 100644 --- a/app/Http/Controllers/AttendanceController.php +++ b/app/Http/Controllers/AttendanceController.php @@ -14,7 +14,7 @@ class AttendanceController extends Controller */ public function __construct() { - $this->middleware('auth'); + $this->middleware(['auth', 'is_admin']); } public function index(Request $request) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 16c0bd2..7354518 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -18,7 +18,7 @@ class UserController extends Controller */ public function __construct() { - $this->middleware('auth'); + $this->middleware(['auth', 'is_admin']); } /** diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 8fdf11b..880eece 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -65,5 +65,6 @@ class Kernel extends HttpKernel 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'is_admin' => \App\Http\Middleware\IsAdmin::class, ]; } diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.php new file mode 100644 index 0000000..9083ad0 --- /dev/null +++ b/app/Http/Middleware/IsAdmin.php @@ -0,0 +1,24 @@ +user()->is_admin) { + return redirect('/home'); + } + + return $next($request); + } +}