BindExportToken.php 580 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use App\Exceptions\ApiException;
  5. class BindExportToken
  6. {
  7. use CheckTokenTrait;
  8. /**
  9. * @param $request
  10. * @param Closure $next
  11. * @return mixed
  12. * @throws ApiException
  13. */
  14. public function handle($request, Closure $next)
  15. {
  16. // 接口中的token(如有则绑定token到全局)
  17. $all = $request->all();
  18. $token = getProp($all, 'd_token');
  19. if ($token) {
  20. $this->checkTokenTrait($token);
  21. }
  22. return $next($request);
  23. }
  24. }