fix: sync window.user.otp when enabling 2FA from the Dashboard

The disable path clears window.user.otp (in UIWindowDisable2FA), but the
enable path updated only the card's DOM, never the in-memory flag. TabSecurity
html() reads user.otp to decide the toggle/badge state, so after enabling 2FA
a re-render of the Security tab from the cached window.user showed it as
disabled for an account that actually had 2FA on.

Set window.user.otp = enabling on success so both directions stay consistent.
This commit is contained in:
jelveh
2026-07-16 19:50:37 -07:00
parent a6c2eab54d
commit 0d18d5bfe9
+5
View File
@@ -155,6 +155,11 @@ const TabSecurity = {
return;
}
// Keep the in-memory flag in sync so a later re-render reflects the
// real 2FA state. The disable dialog already clears window.user.otp;
// the enable path never set it, so the two directions disagreed.
if ( window.user ) window.user.otp = enabling;
const $card = $el_window.find('.dashboard-section-security .dashboard-settings-card-2fa');
if ( enabling ) {
$el_window.find('.dashboard-section-security .user-otp-state').text(i18n('two_factor_enabled'));