mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
This commit is contained in:
@@ -29,8 +29,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Authenticate
|
||||
@@ -47,7 +47,7 @@ class Authenticate
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param Auth $auth
|
||||
* @param Auth $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -59,9 +59,9 @@ class Authenticate
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string[] ...$guards
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param string[] ...$guards
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -78,8 +78,8 @@ class Authenticate
|
||||
/**
|
||||
* Determine if the user is logged in to any of the given guards.
|
||||
*
|
||||
* @param mixed $request
|
||||
* @param array $guards
|
||||
* @param mixed $request
|
||||
* @param array $guards
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
@@ -87,21 +87,26 @@ class Authenticate
|
||||
*/
|
||||
protected function authenticate($request, array $guards)
|
||||
{
|
||||
|
||||
if (empty($guards)) {
|
||||
try {
|
||||
// go for default guard:
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
if (0 === count($guards)) {
|
||||
Log::debug('No guards present.');
|
||||
// go for default guard:
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
if ($this->auth->check()) {
|
||||
Log::debug('Default guard says user is authenticated.');
|
||||
// do an extra check on user object.
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
if ($this->auth->check()) {
|
||||
|
||||
// do an extra check on user object.
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
/** @var User $user */
|
||||
$user = $this->auth->authenticate();
|
||||
if (1 === (int) $user->blocked) {
|
||||
$message = (string) trans('firefly.block_account_logout');
|
||||
/** @var User $user */
|
||||
$user = $this->auth->authenticate();
|
||||
if (null === $user) {
|
||||
Log::warning('User is null, throw exception?');
|
||||
}
|
||||
if (null !== $user) {
|
||||
Log::debug(get_class($user));
|
||||
if (1 === (int)$user->blocked) {
|
||||
$message = (string)trans('firefly.block_account_logout');
|
||||
if ('email_changed' === $user->blocked_code) {
|
||||
$message = (string) trans('firefly.email_changed_logout');
|
||||
$message = (string)trans('firefly.email_changed_logout');
|
||||
}
|
||||
app('session')->flash('logoutMessage', $message);
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
@@ -110,21 +115,12 @@ class Authenticate
|
||||
throw new AuthenticationException('Blocked account.', $guards);
|
||||
}
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
|
||||
throw new FireflyException(
|
||||
sprintf(
|
||||
'It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands? Error: %s',
|
||||
$e->getMessage()
|
||||
), 0, $e
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
|
||||
Log::debug('Guard array is not empty.');
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
@@ -134,6 +130,5 @@ class Authenticate
|
||||
}
|
||||
|
||||
throw new AuthenticationException('Unauthenticated.', $guards);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user