ExternalBackend: Don't throw an error if it's not possible to clean usernames
This commit is contained in:
parent
0bd00ba3d0
commit
3a816ce0f7
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
namespace Icinga\Authentication\User;
|
namespace Icinga\Authentication\User;
|
||||||
|
|
||||||
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
|
||||||
|
@ -105,12 +106,13 @@ class ExternalBackend implements UserBackendInterface
|
||||||
$user->setExternalUserInformation($username, $field);
|
$user->setExternalUserInformation($username, $field);
|
||||||
|
|
||||||
if ($this->stripUsernameRegexp) {
|
if ($this->stripUsernameRegexp) {
|
||||||
$stripped = preg_replace($this->stripUsernameRegexp, '', $username);
|
$stripped = @preg_replace($this->stripUsernameRegexp, '', $username);
|
||||||
if ($stripped !== false) {
|
if ($stripped === false) {
|
||||||
// TODO(el): PHP issues a warning when PHP cannot compile the regular expression. Should we log an
|
Logger::error('Failed to strip external username. The configured regular expression is invalid.');
|
||||||
// additional message in that case?
|
return false;
|
||||||
$username = $stripped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$username = $stripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->setUsername($username);
|
$user->setUsername($username);
|
||||||
|
|
Loading…
Reference in New Issue