for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the EOffice project.
*
* (c) Anthonius Munthi <https://itstoni.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace EOffice\Auth\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Http\Request;
use function response;
class Authenticate
{
/**
* The authentication guard factory instance.
* @var Auth
protected $auth;
* Create a new middleware instance.
* @param Auth $auth
* @return void
public function __construct(Auth $auth)
$this->auth = $auth;
}
* Handle an incoming request.
* @param 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);