Merge pull request #3787 from JosephSilber/core-authenticate
[5.3] Remove the Authenticate middleware
This commit is contained in:
commit
233c93f810
|
@ -46,7 +46,7 @@ class Kernel extends HttpKernel
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $routeMiddleware = [
|
protected $routeMiddleware = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \Illuminate\Http\Middleware\Authenticate::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
|
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Auth\AuthenticationException;
|
|
||||||
|
|
||||||
class Authenticate
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param \Closure $next
|
|
||||||
* @param string ...$guards
|
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Auth\AuthenticationException
|
|
||||||
*/
|
|
||||||
public function handle($request, Closure $next, ...$guards)
|
|
||||||
{
|
|
||||||
$this->authenticate($guards);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the user is logged in to any of the given guards.
|
|
||||||
*
|
|
||||||
* @param array $guards
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Auth\AuthenticationException
|
|
||||||
*/
|
|
||||||
protected function authenticate(array $guards)
|
|
||||||
{
|
|
||||||
if (count($guards) <= 1) {
|
|
||||||
Auth::guard(array_first($guards))->authenticate();
|
|
||||||
|
|
||||||
return Auth::shouldUse($guard);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($guards as $guard) {
|
|
||||||
if (Auth::guard($guard)->check()) {
|
|
||||||
return Auth::shouldUse($guard);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AuthenticationException;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue