diff --git a/app-code/account/index.php b/app-code/account/index.php index 7ee6d52..be99ca8 100644 --- a/app-code/account/index.php +++ b/app-code/account/index.php @@ -483,12 +483,17 @@ if (!isset($_SESSION["logged_in"]) || $_SESSION["logged_in"] !== true) { }), }); const result = await response.json(); + const twofaSwitch = document.getElementById('twofa-switch'); if (response.ok && result.success) { bootstrap.Modal.getInstance(document.getElementById('twofaModal')).hide(); - document.getElementById('2fa-switch').checked = true; + if (twofaSwitch) { + twofaSwitch.checked = true; + } showSuccessModal(result.message || '2FA enabled successfully.'); } else { - document.getElementById('2fa-switch').checked = false; + if (twofaSwitch) { + twofaSwitch.checked = false; + } showErrorModal(result.message || 'Invalid 2FA code.'); } }