Authenticate.php 722 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Traits\UrlWhitelist;
  4. use App\Utils\Admin;
  5. use Closure;
  6. use Illuminate\Auth\Middleware\Authenticate as Middleware;
  7. class Authenticate extends Middleware
  8. {
  9. use UrlWhitelist;
  10. protected $urlWhitelist = [
  11. '/configs/system_basic/values',
  12. ];
  13. public function handle($request, Closure $next, ...$guards)
  14. {
  15. if ($this->shouldPassThrough($request)) {
  16. return $next($request);
  17. } else {
  18. return parent::handle(...func_get_args());
  19. }
  20. }
  21. protected function urlWhitelist(): array
  22. {
  23. return array_map(function ($url) {
  24. return Admin::url($url);
  25. }, $this->urlWhitelist);
  26. }
  27. }