From 60a86546147c761dd6b0b230f9bbcce4011168e3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 21 Apr 2015 13:15:06 +0200 Subject: [PATCH] ExternalBackend: Drop redundant method hasUser refs #8826 --- .../Authentication/User/ExternalBackend.php | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/library/Icinga/Authentication/User/ExternalBackend.php b/library/Icinga/Authentication/User/ExternalBackend.php index 4861ff7de..4f9dd47b3 100644 --- a/library/Icinga/Authentication/User/ExternalBackend.php +++ b/library/Icinga/Authentication/User/ExternalBackend.php @@ -40,33 +40,6 @@ class ExternalBackend extends UserBackend return 1; } - /** - * Test whether the given user exists - * - * @param User $user - * - * @return bool - */ - public function hasUser(User $user) - { - if (isset($_SERVER['REMOTE_USER'])) { - $username = $_SERVER['REMOTE_USER']; - $user->setRemoteUserInformation($username, 'REMOTE_USER'); - if ($this->stripUsernameRegexp) { - $stripped = preg_replace($this->stripUsernameRegexp, '', $username); - if ($stripped !== false) { - // TODO(el): PHP issues a warning when PHP cannot compile the regular expression. Should we log an - // additional message in that case? - $username = $stripped; - } - } - $user->setUsername($username); - return true; - } - - return false; - } - /** * Authenticate * @@ -77,6 +50,23 @@ class ExternalBackend extends UserBackend */ public function authenticate(User $user, $password = null) { - return $this->hasUser($user); + if (isset($_SERVER['REMOTE_USER'])) { + $username = $_SERVER['REMOTE_USER']; + $user->setRemoteUserInformation($username, 'REMOTE_USER'); + + if ($this->stripUsernameRegexp) { + $stripped = preg_replace($this->stripUsernameRegexp, '', $username); + if ($stripped !== false) { + // TODO(el): PHP issues a warning when PHP cannot compile the regular expression. Should we log an + // additional message in that case? + $username = $stripped; + } + } + + $user->setUsername($username); + return true; + } + + return false; } }