diff options
author | Camil Staps | 2016-01-22 12:01:33 +0100 |
---|---|---|
committer | Camil Staps | 2016-01-22 12:01:33 +0100 |
commit | 3a74377e861c1a401f1dffbd595f547e04eb72c8 (patch) | |
tree | 505649f58784ed0e318cb46f28777173bcdc6b90 /app/Http/Middleware/Authenticate.php |
Initial commitlumen-app
Diffstat (limited to 'app/Http/Middleware/Authenticate.php')
-rw-r--r-- | app/Http/Middleware/Authenticate.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..361a11e --- /dev/null +++ b/app/Http/Middleware/Authenticate.php @@ -0,0 +1,44 @@ +<?php + +namespace App\Http\Middleware; + +use Closure; +use Illuminate\Contracts\Auth\Factory as Auth; + +class Authenticate +{ + /** + * The authentication guard factory instance. + * + * @var \Illuminate\Contracts\Auth\Factory + */ + protected $auth; + + /** + * Create a new middleware instance. + * + * @param \Illuminate\Contracts\Auth\Factory $auth + * @return void + */ + public function __construct(Auth $auth) + { + $this->auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * @return mixed + */ + public function handle($request, Closure $next, $guard = null) + { + if ($this->auth->guard($guard)->guest()) { + return response('Unauthorized.', 401); + } + + return $next($request); + } +} |