Autologin: Actually set the username upon authentication

Before, when using autologin the username of the authenticated user always was the empty string.
This commit is contained in:
Eric Lippmann 2014-06-11 15:27:36 +02:00
parent 65a2bd41bc
commit 992ccf4f6d
1 changed files with 8 additions and 5 deletions

View File

@ -55,14 +55,17 @@ class AutoLoginBackend extends UserBackend
{
if (isset($_SERVER['REMOTE_USER'])) {
$username = $_SERVER['REMOTE_USER'];
if ($username !== false) {
if ($this->stripUsernameRegexp !== null) {
$username = preg_replace($this->stripUsernameRegexp, '', $username);
$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;
}