Files
mtdb_movie/common/Core/Middleware/IsAdmin.php
T
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

26 lines
519 B
PHP
Executable File

<?php
namespace Common\Core\Middleware;
use Auth;
use Closure;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
class IsAdmin
{
public function handle(Request $request, Closure $next)
{
if ( ! Auth::check()) {
throw new AuthenticationException();
}
if ( ! Auth::user()->hasPermission('admin')) {
throw new AuthorizationException();
}
return $next($request);
}
}