mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-23 08:43:19 +01:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
|
|
|
class Authenticate extends Middleware
|
|
{
|
|
/**
|
|
* Determine if the user is logged in to any of the given guards.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param array $guards
|
|
* @return void
|
|
*
|
|
* @throws \Illuminate\Auth\AuthenticationException
|
|
*/
|
|
protected function authenticate($request, array $guards)
|
|
{
|
|
if (empty($guards)) {
|
|
// Will retreive the default guard
|
|
$guards = [null];
|
|
} else {
|
|
// We replace routes guard by the reverse proxy guard if necessary
|
|
$proxyGuard = 'reverse-proxy-guard';
|
|
|
|
if (config('auth.defaults.guard') === $proxyGuard) {
|
|
$guards = [$proxyGuard];
|
|
}
|
|
}
|
|
|
|
foreach ($guards as $guard) {
|
|
if ($this->auth->guard($guard)->check()) {
|
|
$this->auth->shouldUse($guard);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
$this->unauthenticated($request, $guards);
|
|
}
|
|
}
|