From b8f81877627f5408dbe568b39eee2c214fd1a728 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Dec 2019 15:34:56 +0100 Subject: [PATCH] AuthBackendPage: Fix crash when external authentication is chosen Only occurred due to PHP 7.4 --- .../application/forms/AuthBackendPage.php | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index 71341e97c..4280c64ea 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -68,7 +68,14 @@ class AuthBackendPage extends Form $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); $backendForm = new DbBackendForm(); $backendForm->setRequiredCue(null); @@ -114,13 +121,6 @@ class AuthBackendPage extends Form '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'); @@ -155,14 +155,18 @@ class AuthBackendPage extends Form return false; } - if ($this->config['type'] === 'ldap' && (! isset($data['skip_validation']) || $data['skip_validation'] == 0)) { - $self = clone $this; - $self->getSubForm('backend_form')->getElement('resource')->setIgnore(false); - $inspection = UserBackendConfigForm::inspectUserBackend($self); - if ($inspection && $inspection->hasError()) { - $this->error($inspection->getError()); - $this->addSkipValidationCheckbox(); - return false; + if (isset($this->config)) { + if ($this->config['type'] === 'ldap' && ( + ! isset($data['skip_validation']) || $data['skip_validation'] == 0) + ) { + $self = clone $this; + $self->getSubForm('backend_form')->getElement('resource')->setIgnore(false); + $inspection = UserBackendConfigForm::inspectUserBackend($self); + if ($inspection && $inspection->hasError()) { + $this->error($inspection->getError()); + $this->addSkipValidationCheckbox(); + return false; + } } }