Working on middleware.
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use Illuminate\Contracts\Routing\Middleware;
|
use Illuminate\Contracts\Routing\Middleware;
|
||||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
|
||||||
|
|
||||||
class Authenticated implements Middleware {
|
class Authenticated implements Middleware {
|
||||||
|
|
||||||
@@ -14,25 +13,15 @@ class Authenticated implements Middleware {
|
|||||||
*/
|
*/
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
/**
|
|
||||||
* The response factory implementation.
|
|
||||||
*
|
|
||||||
* @var ResponseFactory
|
|
||||||
*/
|
|
||||||
protected $response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new filter instance.
|
* Create a new filter instance.
|
||||||
*
|
*
|
||||||
* @param Guard $auth
|
* @param Guard $auth
|
||||||
* @param ResponseFactory $response
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Guard $auth,
|
public function __construct(Guard $auth)
|
||||||
ResponseFactory $response)
|
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->response = $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,11 +37,11 @@ class Authenticated implements Middleware {
|
|||||||
{
|
{
|
||||||
if ($request->ajax())
|
if ($request->ajax())
|
||||||
{
|
{
|
||||||
return $this->response->make('Unauthorized', 401);
|
return response('Unauthorized.', 401);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->response->redirectGuest('auth/login');
|
return redirect()->guest('auth/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user