AuthBackendPage: Fix crash when external authentication is chosen

Only occurred due to PHP 7.4
This commit is contained in:
Johannes Meyer 2019-12-06 15:34:56 +01:00
parent 19dd4b93f1
commit b8f8187762
1 changed files with 20 additions and 16 deletions

View File

@ -68,7 +68,14 @@ class AuthBackendPage extends Form
$this->addSkipValidationCheckbox(); $this->addSkipValidationCheckbox();
} }
if ($this->config['type'] === 'db') { if (! isset($this->config) || $this->config['type'] === 'external') {
$backendForm = new ExternalBackendForm();
$backendForm->create($formData);
$this->addDescription($this->translate(
'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary'
. ' to adjust usernames before any permissions, restrictions, etc. are being applied.'
));
} elseif ($this->config['type'] === 'db') {
$this->setRequiredCue(null); $this->setRequiredCue(null);
$backendForm = new DbBackendForm(); $backendForm = new DbBackendForm();
$backendForm->setRequiredCue(null); $backendForm->setRequiredCue(null);
@ -114,13 +121,6 @@ class AuthBackendPage extends Form
'value' => $type 'value' => $type
) )
); );
} else { // $this->config['type'] === 'external'
$backendForm = new ExternalBackendForm();
$backendForm->create($formData);
$this->addDescription($this->translate(
'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary'
. ' to adjust usernames before any permissions, restrictions, etc. are being applied.'
));
} }
$backendForm->getElement('name')->setValue('icingaweb2'); $backendForm->getElement('name')->setValue('icingaweb2');
@ -155,7 +155,10 @@ class AuthBackendPage extends Form
return false; return false;
} }
if ($this->config['type'] === 'ldap' && (! isset($data['skip_validation']) || $data['skip_validation'] == 0)) { if (isset($this->config)) {
if ($this->config['type'] === 'ldap' && (
! isset($data['skip_validation']) || $data['skip_validation'] == 0)
) {
$self = clone $this; $self = clone $this;
$self->getSubForm('backend_form')->getElement('resource')->setIgnore(false); $self->getSubForm('backend_form')->getElement('resource')->setIgnore(false);
$inspection = UserBackendConfigForm::inspectUserBackend($self); $inspection = UserBackendConfigForm::inspectUserBackend($self);
@ -165,6 +168,7 @@ class AuthBackendPage extends Form
return false; return false;
} }
} }
}
return true; return true;
} }