pelican-panel-mirror/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php
Charles 1900c04b71
Filament v4 🎉 (#1651)
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: Lance Pioch <git@lance.sh>
2025-09-08 13:12:33 -04:00

27 lines
738 B
PHP

<?php
namespace App\Http\Middleware\Api\Application;
use Closure;
use App\Models\User;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AuthenticateApplicationUser
{
/**
* Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceed through the application API.
*/
public function handle(Request $request, Closure $next): mixed
{
/** @var User|null $user */
$user = $request->user();
if (!$user || !$user->isRootAdmin()) {
throw new AccessDeniedHttpException('This account does not have permission to access the API.');
}
return $next($request);
}
}