James Cole
2022-12-11 06:20:27 +01:00
parent c125984d55
commit 922a5fa9c7

View File

@@ -69,6 +69,9 @@ class RemoteUserGuard implements Guard
// Get the user identifier from $_SERVER or apache filtered headers
$header = config('auth.guard_header', 'REMOTE_USER');
$userID = request()->server($header) ?? apache_request_headers()[$header] ?? null;
$userID = 'james@firefly';
if (null === $userID) {
Log::error(sprintf('No user in header "%s".', $header));
throw new FireflyException('The guard header was unexpectedly empty. See the logs.');
@@ -79,12 +82,18 @@ class RemoteUserGuard implements Guard
// store email address if present in header and not already set.
$header = config('auth.guard_email');
$header = 'abc';
if (null !== $header) {
$emailAddress = (string) (request()->server($header) ?? null);
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
$emailAddress = 'test2@nder.be';
if (null !== $emailAddress && null === $preference && $emailAddress !== $userID) {
if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {
app('preferences')->setForUser($retrievedUser, 'remote_guard_alt_email', $emailAddress);
}
// if the pref isn't null and the object returned isn't null, update the email address.
if ('' !== $emailAddress && null !== $preference && $emailAddress !== $preference->data) {
app('preferences')->setForUser($retrievedUser, 'remote_guard_alt_email', $emailAddress);
}
}