diff --git a/app/Http/Filters/AuthFilter.php b/app/Http/Filters/AuthFilter.php index 0bf83ab2..d4f004cb 100644 --- a/app/Http/Filters/AuthFilter.php +++ b/app/Http/Filters/AuthFilter.php @@ -2,30 +2,59 @@ use Illuminate\Http\Request; use Illuminate\Routing\Route; -use Auth, Redirect, Response; +use Illuminate\Contracts\Auth\Authenticator; +use Illuminate\Contracts\Routing\ResponseFactory; 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 (Auth::guest()) - { - if ($request->ajax()) - { - return Response::make('Unauthorized', 401); - } - else - { - return Redirect::guest('auth/login'); - } - } - } + /** + * The authenticator implementation. + * + * @var Authenticator + */ + protected $auth; + + /** + * The response factory implementation. + * + * @var ResponseFactory + */ + protected $response; + + /** + * Create a new filter instance. + * + * @param Authenticator $auth + * @param ResponseFactory $response + * @return void + */ + public function __construct(Authenticator $auth, + ResponseFactory $response) + { + $this->auth = $auth; + $this->response = $response; + } + + /** + * 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'); + } + } + } } diff --git a/app/Http/Filters/BasicAuthFilter.php b/app/Http/Filters/BasicAuthFilter.php index fbc0a8c2..77a37296 100644 --- a/app/Http/Filters/BasicAuthFilter.php +++ b/app/Http/Filters/BasicAuthFilter.php @@ -1,9 +1,27 @@ auth = $auth; + } + /** * Run the request filter. * @@ -11,7 +29,7 @@ class BasicAuthFilter { */ public function filter() { - return Auth::basic(); + return $this->auth->basic(); } -} \ No newline at end of file +} diff --git a/app/Http/Filters/CsrfFilter.php b/app/Http/Filters/CsrfFilter.php index 6056f9ee..3ded7153 100644 --- a/app/Http/Filters/CsrfFilter.php +++ b/app/Http/Filters/CsrfFilter.php @@ -1,6 +1,5 @@ input('_token')) + if ($request->getSession()->token() != $request->input('_token')) { throw new TokenMismatchException; } diff --git a/app/Http/Filters/GuestFilter.php b/app/Http/Filters/GuestFilter.php deleted file mode 100644 index 752efc2e..00000000 --- a/app/Http/Filters/GuestFilter.php +++ /dev/null @@ -1,20 +0,0 @@ -app = $app; + $this->response = $response; + } + /** * Run the request filter. * @@ -11,9 +38,9 @@ class MaintenanceFilter { */ public function filter() { - if (App::isDownForMaintenance()) + if ($this->app->isDownForMaintenance()) { - return Response::make('Be right back!'); + return $this->response->make('Be right back!', 503); } }