fix: askPassword closure — pw declared inside function (was global ref)
Build Fechamento de Caixa / build (macos-14, app) (push) Has been cancelled
Build Fechamento de Caixa / build (ubuntu-22.04, deb) (push) Has been cancelled
Build Fechamento de Caixa / build (windows-2022, msi) (push) Has been cancelled

This commit is contained in:
root
2026-06-30 14:06:45 +00:00
parent 80740afbf0
commit cbaef8772d
+9 -4
View File
@@ -2474,8 +2474,10 @@ window.toggleEditConsulta = async function() {
openEditModal(full);
};
// Pede senha admin — retorna Promise<boolean>
function askPassword() {
return new Promise(resolve => {
const pw = config.admin_password;
const overlay = document.createElement('div');
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
overlay.id = 'pw-modal';
@@ -2485,21 +2487,24 @@ function askPassword() {
<input type="password" id="pw-input" placeholder="Digite a senha..." style="width:100%;padding:10px;font-size:14px;border:1px solid #ccc;border-radius:6px;box-sizing:border-box;margin-bottom:12px" />
<div id="pw-error" style="color:#c0272d;font-size:12px;margin-bottom:8px;display:none">Senha incorreta</div>
<div style="display:flex;gap:8px;justify-content:center">
<button onclick="document.getElementById('pw-modal').remove();window._pwResult=false;window._pwResolve&&window._pwResolve(false)" style="padding:8px 16px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer">Cancelar</button>
<button id="pw-cancel-btn" style="padding:8px 16px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer">Cancelar</button>
<button id="pw-ok-btn" style="padding:8px 16px;background:#e65100;color:#fff;border:none;border-radius:6px;cursor:pointer">OK</button>
</div>
</div>`;
document.body.appendChild(overlay);
const inp = document.getElementById('pw-input');
inp.focus();
window._pwResolve = resolve;
document.getElementById('pw-cancel-btn').addEventListener('click', () => {
document.getElementById('pw-modal').remove();
resolve(false);
});
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
document.getElementById('pw-ok-btn').addEventListener('click', () => {
const val = document.getElementById('pw-input').value;
if (val === pw) {
document.getElementById('pw-modal').remove();
window._pwResult = true;
window._pwResolve && window._pwResolve(true);
resolve(true);
} else {
document.getElementById('pw-error').style.display = 'block';
inp.value = '';