mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 10:27:46 +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()
|
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(
|
$this->addElement(
|
||||||
'note',
|
'note',
|
||||||
@ -318,7 +318,7 @@ class TotpForm extends PreferenceForm
|
|||||||
$this->preferences = new Preferences($this->store ? $this->store->load() : array());
|
$this->preferences = new Preferences($this->store ? $this->store->load() : array());
|
||||||
$webPreferences = $this->preferences->get('icingaweb');
|
$webPreferences = $this->preferences->get('icingaweb');
|
||||||
if ($this->totp->hasPendingChanges()
|
if ($this->totp->hasPendingChanges()
|
||||||
|| $this->getValue('enabled_2fa') !== $webPreferences['enabled_2fa']) {
|
|| $this->getValue('enabled_2fa') !== ($webPreferences['enabled_2fa'] ?? null)) {
|
||||||
if (!$this->totp->requiresSecretCheck()) {
|
if (!$this->totp->requiresSecretCheck()) {
|
||||||
foreach ($this->getValues() as $key => $value) {
|
foreach ($this->getValues() as $key => $value) {
|
||||||
if (in_array($key, self::PREFERENCE_KEYS, true)) {
|
if (in_array($key, self::PREFERENCE_KEYS, true)) {
|
||||||
@ -375,7 +375,7 @@ class TotpForm extends PreferenceForm
|
|||||||
} elseif ($this->getElement('btn_cancel_totp')
|
} elseif ($this->getElement('btn_cancel_totp')
|
||||||
&& $this->getElement('btn_cancel_totp')->isChecked()) {
|
&& $this->getElement('btn_cancel_totp')->isChecked()) {
|
||||||
$this->totp->resetChanges();
|
$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');
|
Session::getSession()->delete('enabled_2fa');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -401,9 +401,10 @@ class TotpForm extends PreferenceForm
|
|||||||
if (($enabled = Session::getSession()->get('enabled_2fa', null)) !== null) {
|
if (($enabled = Session::getSession()->get('enabled_2fa', null)) !== null) {
|
||||||
$values['enabled_2fa'] = $enabled == 1 ? '1' : '0';
|
$values['enabled_2fa'] = $enabled == 1 ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
if (isset($values)) {
|
||||||
$this->populate($values);
|
$this->populate($values);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isSubmitted()
|
public function isSubmitted()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user