Created
September 11, 2014 15:08
-
-
Save alnutile/65e6ef8e961cc28bbd86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php namespace BehatEditor\Http\Filters; | |
| use Illuminate\Http\Request; | |
| use Illuminate\Routing\Route; | |
| use Auth, Redirect, Response; | |
| class AuthFilter { | |
| /** | |
| * Run the request filter. | |
| * | |
| * @param \Illuminate\Routing\Route $route | |
| * @param \Illuminate\Http\Request $request | |
| * @return mixed | |
| */ | |
| public function filter(Route $route, Request $request) | |
| { | |
| if(\App::isLocal() !== true) { | |
| if (Auth::guest()) | |
| { | |
| if ($request->ajax()) | |
| { | |
| return Response::make('Unauthorized', 401); | |
| } | |
| else | |
| { | |
| return Redirect::guest('auth/login'); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment