CheckProMember.php 764 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Illuminate\Http\Request;
  5. class CheckProMember
  6. {
  7. /**
  8. * Handle an incoming request.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @param \Closure $next
  12. * @return mixed
  13. */
  14. public function handle(Request $request, Closure $next)
  15. {
  16. if (session()->missing('member.is_member')) {
  17. if (isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe') {
  18. echo "<script>window.top.location.href = '/member-login'; </script>";
  19. } else {
  20. return redirect()->route('member-login')->with(['url.intended' => url()->current()]);
  21. }
  22. }
  23. return $next($request);
  24. }
  25. }