diff options
author | Camil Staps | 2016-09-05 22:30:47 +0200 |
---|---|---|
committer | Camil Staps | 2016-09-05 22:30:47 +0200 |
commit | fc5cef0efddbb1141b0a371108a23fc7f6e8d860 (patch) | |
tree | 8b3e62b50e5f856c57af477a78a51567d6e859f2 /app/Http/Middleware | |
parent | User creation and authentication (diff) |
Vote on verb suggestions
Diffstat (limited to 'app/Http/Middleware')
-rw-r--r-- | app/Http/Middleware/Login.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/Http/Middleware/Login.php b/app/Http/Middleware/Login.php new file mode 100644 index 0000000..8a71104 --- /dev/null +++ b/app/Http/Middleware/Login.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Http\Middleware; + +use Closure; +use Illuminate\Support\Facades\Auth; + +class Login { + /** + * Create a new middleware instance. + * + * @param \Illuminate\Contracts\Auth\Factory $auth + * @return void + */ + public function __construct() { + } + + /** + * 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 ($request->has('login') && !Auth::check()) { + return response('Unauthorized.', 401) + ->header('WWW-Authenticate', 'Basic realm="Please enter your email and password"'); + } + + return $next($request); + } +} |