Admin.php 806 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Illuminate\Support\Facades\Auth;
  5. use Illuminate\Support\Facades\Log;
  6. class Admin
  7. {
  8. /**
  9. * Handle an incoming request.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @param \Closure $next
  13. * @return mixed
  14. */
  15. public function handle($request, Closure $next, $guard = null)
  16. {
  17. $auth = Auth::guard($guard);
  18. if (Auth::guard($guard)->guest()) {
  19. if ($request->ajax() || $request->wantsJson()) {
  20. return response('Unauthorized.', 401);
  21. } else {
  22. return redirect()->guest('/');
  23. }
  24. }
  25. if ($auth->user()->email != 'admin@geolook.com') {
  26. return abort(404);
  27. }
  28. return $next($request);
  29. }
  30. }