2015-08-30 13:22:00 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-24 03:22:14 +02:00
|
|
|
namespace Poniverse\Ponyfm\Http\Middleware;
|
2015-08-30 13:22:00 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|