Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

35 lines
789B

  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Exception;
  5. use Illuminate\Http\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. class FromKintoneMiddleware
  8. {
  9. /**
  10. * Handle an incoming request.
  11. *
  12. * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
  13. */
  14. public function handle(Request $request, Closure $next): Response
  15. {
  16. $currectToken = config('kintone.fromKintoneToken');
  17. if ($request['token'] !== $currectToken) {
  18. if ($request->wantsJson()) {
  19. return response()->json([
  20. 'RESULT' => "UNAUTHORIZED",
  21. ]);
  22. } else {
  23. abort(403);
  24. }
  25. }
  26. return $next($request);
  27. }
  28. }