diff -r 3079cbf80006 -r 8d688175513a server/src/app/Http/Middleware/Authenticate.php --- a/server/src/app/Http/Middleware/Authenticate.php Fri Mar 04 10:08:52 2016 +0100 +++ b/server/src/app/Http/Middleware/Authenticate.php Fri Mar 04 19:18:28 2016 +0100 @@ -3,42 +3,25 @@ namespace CorpusParole\Http\Middleware; use Closure; -use Illuminate\Contracts\Auth\Guard; +use Illuminate\Support\Facades\Auth; class Authenticate { /** - * The Guard implementation. - * - * @var Guard - */ - protected $auth; - - /** - * Create a new filter instance. - * - * @param Guard $auth - */ - public function __construct(Guard $auth) - { - $this->auth = $auth; - } - - /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard * @return mixed */ - public function handle($request, Closure $next) + public function handle($request, Closure $next, $guard = null) { - if ($this->auth->guest()) { - if ($request->ajax()) { + if (Auth::guard($guard)->guest()) { + if ($request->ajax() || $request->wantsJson()) { return response('Unauthorized.', 401); } else { - return redirect()->guest('auth/login'); + return redirect()->guest('login'); } }