Files
mtdb_movie/common/Core/Middleware/IsAdmin.php
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01: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);
}
}