- Move PayPal live/sandbox API keys to env variables - Move hardcoded API token in isAuthorized middleware to env variable - Add api_token key to config/app.php - Update .env.example with new required env vars - Fix isAuthorized response code from 503 to 401
24 lines
515 B
PHP
24 lines
515 B
PHP
<?php namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
|
|
class isAuthorized {
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$token = $request->header('token') ?? (getallheaders()['token'] ?? null);
|
|
if ($token && $token === config('app.api_token')) {
|
|
return $next($request);
|
|
}
|
|
return response()->json(['status' => false, 'error' => 'Invalid request'], 401);
|
|
}
|
|
|
|
}
|