ExternalBackend: Drop redundant method hasUser

refs #8826
This commit is contained in:
Johannes Meyer 2015-04-21 13:15:06 +02:00
parent 11f522d929
commit 60a8654614
1 changed files with 18 additions and 28 deletions

View File

@ -40,33 +40,6 @@ class ExternalBackend extends UserBackend
return 1; 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 * Authenticate
* *
@ -77,6 +50,23 @@ class ExternalBackend extends UserBackend
*/ */
public function authenticate(User $user, $password = null) 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;
} }
} }