예제 #1
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @return mixed
  */
 public function filter(Route $route, Request $request)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return $this->response->make('Unauthorized', 401);
         } else {
             return $this->response->redirectGuest('auth/login');
         }
     }
 }
예제 #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return $this->response->make('Unauthorized', 401);
         } else {
             return $this->response->redirectGuest('auth/login');
         }
     }
     return $next($request);
 }