2018-01-19 03:36:15 +00:00
|
|
|
<?php
|
|
|
|
|
2018-02-25 21:30:56 +00:00
|
|
|
namespace Pterodactyl\Http\Middleware\Api\Client;
|
2018-01-19 03:36:15 +00:00
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
|
|
|
|
2018-02-25 21:30:56 +00:00
|
|
|
class AuthenticateClientAccess
|
2018-01-19 03:36:15 +00:00
|
|
|
{
|
|
|
|
/**
|
2018-02-25 21:30:56 +00:00
|
|
|
* Authenticate that the currently authenticated user has permission
|
|
|
|
* to access the specified server.
|
2018-01-19 03:36:15 +00:00
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
|
|
{
|
2018-02-25 21:30:56 +00:00
|
|
|
if (is_null($request->user())) {
|
|
|
|
throw new AccessDeniedHttpException('This account does not have permission to access this resource.');
|
2018-01-19 03:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|