for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Distilleries\Expendable\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Config\Repository;
class Authenticate {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
protected $config;
* Create a new filter instance.
* @param Guard $auth
public function __construct(Guard $auth, Repository $config)
{
$this->auth = $auth;
$this->config = $config;
}
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
public function handle($request, Closure $next)
if ($this->auth->guest())
if ($request->ajax())
return response('Unauthorized.', 401);
} else
return redirect()->guest($this->config->get('expendable.login_uri'));
return $next($request);