mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-23 18:07:42 +02:00
Fix: prevent error if enabled-2fa isn't set
This commit is contained in:
parent
ee68271b12
commit
690f94f3db
@ -246,7 +246,7 @@ class TotpForm extends PreferenceForm
|
||||
}
|
||||
|
||||
if ($this->totp->hasPendingChanges()
|
||||
|| ($this->preferences->get('icingaweb')['enabled_2fa'] ?? '0') !== $formData['enabled_2fa'] ?? '0'
|
||||
|| ($this->preferences->get('icingaweb')['enabled_2fa'] ?? '0') !== ($formData['enabled_2fa'] ?? '0')
|
||||
) {
|
||||
$this->addElement(
|
||||
'note',
|
||||
@ -318,7 +318,7 @@ class TotpForm extends PreferenceForm
|
||||
$this->preferences = new Preferences($this->store ? $this->store->load() : array());
|
||||
$webPreferences = $this->preferences->get('icingaweb');
|
||||
if ($this->totp->hasPendingChanges()
|
||||
|| $this->getValue('enabled_2fa') !== $webPreferences['enabled_2fa']) {
|
||||
|| $this->getValue('enabled_2fa') !== ($webPreferences['enabled_2fa'] ?? null)) {
|
||||
if (!$this->totp->requiresSecretCheck()) {
|
||||
foreach ($this->getValues() as $key => $value) {
|
||||
if (in_array($key, self::PREFERENCE_KEYS, true)) {
|
||||
@ -375,7 +375,7 @@ class TotpForm extends PreferenceForm
|
||||
} elseif ($this->getElement('btn_cancel_totp')
|
||||
&& $this->getElement('btn_cancel_totp')->isChecked()) {
|
||||
$this->totp->resetChanges();
|
||||
$this->enabled2FA = $this->preferences->get('icingaweb')['enabled_2fa'] === '1';
|
||||
$this->enabled2FA = ($this->preferences->get('icingaweb')['enabled_2fa'] ?? null) === '1';
|
||||
Session::getSession()->delete('enabled_2fa');
|
||||
|
||||
return true;
|
||||
@ -401,9 +401,10 @@ class TotpForm extends PreferenceForm
|
||||
if (($enabled = Session::getSession()->get('enabled_2fa', null)) !== null) {
|
||||
$values['enabled_2fa'] = $enabled == 1 ? '1' : '0';
|
||||
}
|
||||
|
||||
if (isset($values)) {
|
||||
$this->populate($values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isSubmitted()
|
||||
|
Loading…
x
Reference in New Issue
Block a user