Add more middleware tests
This commit is contained in:
parent
133fd17da6
commit
7882250baf
13 changed files with 515 additions and 48 deletions
|
@ -11,10 +11,8 @@ namespace Pterodactyl\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class DaemonAuthenticate
|
||||
{
|
||||
|
@ -56,15 +54,10 @@ class DaemonAuthenticate
|
|||
}
|
||||
|
||||
if (! $request->header('X-Access-Node')) {
|
||||
throw new HttpException(403);
|
||||
}
|
||||
|
||||
try {
|
||||
$node = $this->repository->findWhere(['daemonSecret' => $request->header('X-Access-Node')]);
|
||||
} catch (RecordNotFoundException $exception) {
|
||||
throw new HttpException(401);
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
$node = $this->repository->findWhere(['daemonSecret' => $request->header('X-Access-Node')]);
|
||||
$request->attributes->set('node', $node);
|
||||
|
||||
return $next($request);
|
||||
|
|
Reference in a new issue