| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function handle($request, Closure $next) |
||
| 30 | { |
||
| 31 | $authToken = $request->header('X-Auth-Token'); |
||
| 32 | |||
| 33 | if (is_null($authToken)) { |
||
| 34 | throw new HttpException(Response::HTTP_UNAUTHORIZED, 'Token not set', null, ['X-Auth-Token']); |
||
| 35 | } |
||
| 36 | |||
| 37 | try { |
||
| 38 | $dedicatedServer = DedicatedServer::where('gdaemon_api_token', '=', $authToken)->firstOrFail(); |
||
| 39 | } catch (ModelNotFoundException $exception) { |
||
| 40 | throw new InvalidTokenExeption('Invalid api token'); |
||
| 41 | } |
||
| 42 | |||
| 43 | app()->instance(DedicatedServer::class, $dedicatedServer); |
||
| 44 | |||
| 45 | return $next($request); |
||
| 46 | } |
||
| 48 |