From c61b156f1bd93ec4aadd8adc78523b42b0232918 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 4 Sep 2016 23:30:15 +0200 Subject: User creation and authentication --- app/Http/Middleware/Authenticate.php | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/Http/Middleware/Authenticate.php (limited to 'app/Http/Middleware/Authenticate.php') diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..6db8bb0 --- /dev/null +++ b/app/Http/Middleware/Authenticate.php @@ -0,0 +1,45 @@ +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) + ->header('WWW-Authenticate', 'Basic realm="Please enter your email and password"'); + } + + return $next($request); + } +} -- cgit v1.2.3