BindExportToken.php 658 B

123456789101112131415161718192021222324252627282930
  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. $channelId = getProp($all, 'd_channel_id');
  20. if ($token && $channelId) {
  21. $this->checkTokenTrait($token, $channelId);
  22. }
  23. return $next($request);
  24. }
  25. }