2021-06-22 18:51:58 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
|
use Illuminate\Http\Request;
|
2021-12-14 16:22:03 +08:00
|
|
|
use Illuminate\Validation\UnauthorizedException;
|
2021-06-22 18:51:58 +08:00
|
|
|
|
|
|
|
|
class Platform
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Handle an incoming request.
|
|
|
|
|
*
|
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
|
* @param \Closure $next
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
|
|
|
{
|
2022-03-31 22:22:04 +08:00
|
|
|
$platform = nexus()->getPlatform();
|
|
|
|
|
if (empty($platform)) {
|
2021-06-22 18:51:58 +08:00
|
|
|
throw new \InvalidArgumentException("Require platform header.");
|
|
|
|
|
}
|
2022-03-20 22:14:00 +08:00
|
|
|
if (!nexus()->isPlatformValid()) {
|
2022-03-31 22:22:04 +08:00
|
|
|
throw new \InvalidArgumentException("Invalid platform: " . $platform);
|
2021-06-22 18:51:58 +08:00
|
|
|
}
|
|
|
|
|
return $next($request);
|
|
|
|
|
}
|
|
|
|
|
}
|