Make regular expression pattern in autologin backend being fully optional

This commit is contained in:
Johannes Meyer 2014-10-20 15:14:14 +02:00
parent 09945994b8
commit 8c62c66a4e
3 changed files with 2 additions and 3 deletions

View File

@ -50,7 +50,6 @@ class AutologinBackendForm extends Form
'text',
'strip_username_regexp',
array(
'required' => true,
'label' => t('Backend Domain Pattern'),
'description' => t('The domain pattern of this authentication backend'),
'value' => '/\@[^$]+$/',

View File

@ -220,7 +220,7 @@ class AdminAccountPage extends Form
}
$name = $_SERVER['REMOTE_USER'];
if (isset($this->backendConfig['strip_username_regexp'])) {
if (isset($this->backendConfig['strip_username_regexp']) && $this->backendConfig['strip_username_regexp']) {
// No need to silence or log anything here because the pattern has
// already been successfully compiled during backend configuration
$name = preg_replace($this->backendConfig['strip_username_regexp'], '', $name);

View File

@ -54,7 +54,7 @@ class AutoLoginBackend extends UserBackend
if (isset($_SERVER['REMOTE_USER'])) {
$username = $_SERVER['REMOTE_USER'];
$user->setRemoteUserInformation($username, 'REMOTE_USER');
if ($this->stripUsernameRegexp !== null) {
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