update getallheaders
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
<?php namespace App\Http\Middleware;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|
||||||
class isAuthorized {
|
class isAuthorized
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
@@ -13,11 +16,21 @@ class isAuthorized {
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if(isset(getallheaders()['token']) && getallheaders()['token']=="1HHIaIsT4pvO2S39vMzlVfGWi3AhAz6F5xGBNKil") {
|
if (isset(getallheaders()['token']) && getallheaders()['token'] == "1HHIaIsT4pvO2S39vMzlVfGWi3AhAz6F5xGBNKil") {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}else{
|
} else {
|
||||||
return response()->json(['status' => false,'error' => "Invalid request"], 503);
|
return response()->json(['status' => false, 'error' => "Invalid request"], 503);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getallheaders()
|
||||||
|
{
|
||||||
|
$headers = [];
|
||||||
|
foreach ($_SERVER as $name => $value) {
|
||||||
|
if (substr($name, 0, 5) == 'HTTP_') {
|
||||||
|
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $headers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user