misc_pterodactyl-panel/app/Http/Middleware/Api/Application/AuthenticateUser.php

28 lines
727 B
PHP
Raw Normal View History

2018-01-19 03:36:15 +00:00
<?php
2018-01-20 01:58:57 +00:00
namespace Pterodactyl\Http\Middleware\Api\Application;
2018-01-19 03:36:15 +00:00
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AuthenticateUser
{
/**
* Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceede through the application API.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (is_null($request->user()) || ! $request->user()->root_admin) {
throw new AccessDeniedHttpException;
}
return $next($request);
}
}