AuthenticatedWithBasicAuth.php 679 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php namespace App\Http\Middleware;
  2. use Closure;
  3. use Illuminate\Contracts\Auth\Guard;
  4. use Illuminate\Contracts\Routing\Middleware;
  5. class AuthenticatedWithBasicAuth implements Middleware {
  6. /**
  7. * The Guard implementation.
  8. *
  9. * @var Guard
  10. */
  11. protected $auth;
  12. /**
  13. * Create a new filter instance.
  14. *
  15. * @param Guard $auth
  16. * @return void
  17. */
  18. public function __construct(Guard $auth)
  19. {
  20. $this->auth = $auth;
  21. }
  22. /**
  23. * Handle an incoming request.
  24. *
  25. * @param \Illuminate\Http\Request $request
  26. * @param \Closure $next
  27. * @return mixed
  28. */
  29. public function handle($request, Closure $next)
  30. {
  31. return $this->auth->basic() ?: $next($request);
  32. }
  33. }