mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Update changelog, fix log reference.
This commit is contained in:
@@ -31,6 +31,7 @@ use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class RemoteUserGuard
|
||||
@@ -48,7 +49,7 @@ class RemoteUserGuard implements Guard
|
||||
{
|
||||
/** @var null|Request $request */
|
||||
$request = $app->get('request');
|
||||
app('log')->debug(sprintf('Created RemoteUserGuard for %s "%s"', $request?->getMethod(), $request?->getRequestUri()));
|
||||
Log::debug(sprintf('Created RemoteUserGuard for %s "%s"', $request?->getMethod(), $request?->getRequestUri()));
|
||||
$this->application = $app;
|
||||
$this->provider = $provider;
|
||||
$this->user = null;
|
||||
@@ -56,9 +57,9 @@ class RemoteUserGuard implements Guard
|
||||
|
||||
public function authenticate(): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
if (null !== $this->user) {
|
||||
app('log')->debug(sprintf('%s is found: #%d, "%s".', get_class($this->user), $this->user->id, $this->user->email));
|
||||
Log::debug(sprintf('%s is found: #%d, "%s".', get_class($this->user), $this->user->id, $this->user->email));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -67,17 +68,17 @@ class RemoteUserGuard implements Guard
|
||||
$userID = request()->server($header) ?? null;
|
||||
|
||||
if (function_exists('apache_request_headers')) {
|
||||
app('log')->debug('Use apache_request_headers to find user ID.');
|
||||
Log::debug('Use apache_request_headers to find user ID.');
|
||||
$userID = request()->server($header) ?? apache_request_headers()[$header] ?? null;
|
||||
}
|
||||
|
||||
if (null === $userID || '' === $userID) {
|
||||
app('log')->error(sprintf('No user in header "%s".', $header));
|
||||
Log::error(sprintf('No user in header "%s".', $header));
|
||||
|
||||
throw new FireflyException('The guard header was unexpectedly empty. See the logs.');
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('User ID found in header is "%s"', $userID));
|
||||
Log::debug(sprintf('User ID found in header is "%s"', $userID));
|
||||
|
||||
/** @var User $retrievedUser */
|
||||
$retrievedUser = $this->provider->retrieveById($userID);
|
||||
@@ -98,30 +99,30 @@ class RemoteUserGuard implements Guard
|
||||
}
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('Result of getting user from provider: %s', $retrievedUser->email));
|
||||
Log::debug(sprintf('Result of getting user from provider: %s', $retrievedUser->email));
|
||||
$this->user = $retrievedUser;
|
||||
}
|
||||
|
||||
public function guest(): bool
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return !$this->check();
|
||||
}
|
||||
|
||||
public function check(): bool
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return null !== $this->user();
|
||||
}
|
||||
|
||||
public function user(): ?User
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
$user = $this->user;
|
||||
if (null === $user) {
|
||||
app('log')->debug('User is NULL');
|
||||
Log::debug('User is NULL');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ class RemoteUserGuard implements Guard
|
||||
|
||||
public function hasUser(): bool
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
throw new FireflyException('Did not implement RemoteUserGuard::hasUser()');
|
||||
}
|
||||
@@ -141,20 +142,20 @@ class RemoteUserGuard implements Guard
|
||||
*/
|
||||
public function id(): null|int|string
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return $this->user?->id;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void // @phpstan-ignore-line
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->error(sprintf('Did not set user at %s', __METHOD__));
|
||||
Log::error(sprintf('Did not set user at %s', __METHOD__));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,14 +165,14 @@ class RemoteUserGuard implements Guard
|
||||
*/
|
||||
public function validate(array $credentials = []): bool
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
throw new FireflyException('Did not implement RemoteUserGuard::validate()');
|
||||
}
|
||||
|
||||
public function viaRemember(): bool
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user