Source
xxxxxxxxxx
_('After this change, users who have already enrolled in this MFA method will have to complete the enrollment process again because TOTP secrets will be reset.')
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* @var CView $this
*/
?>
window.mfa_edit = new class {
/**
* @var {Overlay}
*/
#overlay;
/**
* @type {HTMLDivElement}
*/
#dialogue;
/**
* @type {HTMLFormElement}
*/
#form;
/**
* @type {string | null}
*/
#mfaid;
/**
* @type {Object}
*/
#change_sensitive_data;
init({mfaid, change_sensitive_data}) {
this.#overlay = overlays_stack.getById('mfa_edit');
this.#dialogue = this.#overlay.$dialogue[0];
this.#form = this.#overlay.$dialogue.$body[0].querySelector('form');
this.#mfaid = mfaid;
this.#change_sensitive_data = change_sensitive_data;
this.#addEventListeners();
this.#updateForm();
}
#addEventListeners() {
this.#form.querySelector('[name=type]').addEventListener('change', () => {
this.#updateForm();
});
const client_secret_button = document.getElementById('client-secret-btn');
if (client_secret_button !== null) {
client_secret_button.addEventListener('click', this.#showClientSecretField);
}
}
#updateForm() {
const type = this.#form.querySelector('[name="type"]').value;
for (const element_class of ['js-hash-function', 'js-code-length']) {
for (const element of this.#form.querySelectorAll(`.${element_class}`)) {
element.style.display = type == MFA_TYPE_TOTP ? '' : 'none';
}
}
for (const element_class of ['js-api-hostname', 'js-clientid', 'js-client-secret']) {
for (const element of this.#form.querySelectorAll(`.${element_class}`)) {
element.style.display = type == MFA_TYPE_DUO ? '' : 'none';
}
}
}
#showClientSecretField(e) {
const form_field = e.target.parentNode;