From 9082a7d9b9808a5de0f839d868d8d8e3429701fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sat, 14 Nov 2020 18:41:29 +0100 Subject: [PATCH] Fix error on missing AUTHENTICATION_GUARD_EMAIL Fixes #4060 --- app/Support/Authentication/RemoteUserGuard.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php index cf8d4688ce..4d4867b813 100644 --- a/app/Support/Authentication/RemoteUserGuard.php +++ b/app/Support/Authentication/RemoteUserGuard.php @@ -80,11 +80,14 @@ class RemoteUserGuard implements Guard // store email address if present in header and not already set. $header = config('auth.guard_email'); - $emailAddress = (string) (request()->server($header) ?? null); - $preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email', null); - if (null !== $emailAddress && null === $preference && $emailAddress !== $userID) { - app('preferences')->setForUser($retrievedUser, 'remote_guard_alt_email', $emailAddress); + if (null !== $header) { + $emailAddress = (string) (request()->server($header) ?? null); + $preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email', null); + + if (null !== $emailAddress && null === $preference && $emailAddress !== $userID) { + app('preferences')->setForUser($retrievedUser, 'remote_guard_alt_email', $emailAddress); + } } Log::debug(sprintf('Result of getting user from provider: %s', $retrievedUser->email));