2015-08-30 13:22:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Contracts\Auth\Guard;
|
|
|
|
|
|
|
|
class Authenticate
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The Guard implementation.
|
|
|
|
*
|
|
|
|
* @var Guard
|
|
|
|
*/
|
|
|
|
protected $auth;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new filter instance.
|
|
|
|
*
|
2015-09-06 17:57:20 +02:00
|
|
|
* @param Guard $auth
|
2015-08-30 13:22:00 +02:00
|
|
|
*/
|
|
|
|
public function __construct(Guard $auth)
|
|
|
|
{
|
|
|
|
$this->auth = $auth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
2015-09-06 17:57:20 +02:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
2015-08-30 13:22:00 +02:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
if ($this->auth->guest()) {
|
2015-09-06 17:57:20 +02:00
|
|
|
return redirect()->guest('login');
|
2015-08-30 13:22:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|