Skip to content

Commit

Permalink
Adding Middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ModestasV committed Sep 2, 2024
1 parent 01f4caf commit 2307578
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/Http/Middleware/IsAdminMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class IsAdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (!auth()->check() || !auth()->user()->is_admin) {
abort(Response::HTTP_FORBIDDEN);
}

return $next($request);
}
}

0 comments on commit 2307578

Please sign in to comment.