hashids = $hashids; $this->repository = $repository; } /** * Determine if a user has permission to access and modify subuser. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Pterodactyl\Exceptions\DisplayException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function handle(Request $request, Closure $next) { $server = $request->attributes->get('server'); $hash = $request->route()->parameter('subuser', 0); $subuser = $this->repository->find($this->hashids->decodeFirst($hash, 0)); if (! $subuser || $subuser->server_id !== $server->id) { throw new NotFoundHttpException; } if ($request->method() === 'PATCH') { if ($subuser->user_id === $request->user()->id) { throw new DisplayException(trans('exceptions.subusers.editing_self')); } } $request->attributes->set('subuser', $subuser); return $next($request); } }