diff --git a/web/public/app.js b/web/public/app.js index d238fd6..7d264c8 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -2601,15 +2601,23 @@ function renderDetailCoverage(detail) { // Auth & Keys modal // --------------------------------------------------------------------------- -function openAuthModal() { +function selectAuthTab(name) { + $$('.modal-tab').forEach((t) => t.classList.toggle('active', t.dataset.mtab === name)); + $$('.modal-panel').forEach((p) => show(p, p.dataset.mpanel === name)); +} + +// The tab state survives between opens, so reset it explicitly: opening from +// "Authentication" must show Target login, not whatever tab was used last. +function openAuthModal(tab = 'target') { show($('#authModal'), true); + selectAuthTab(tab); renderRoleList(); $('#credsPath').value = state.credsPath; $('#collectionPath').value = state.collectionPath; refreshKeyStatus(); } -['#btnOpenAuth2', '#btnOpenAuth3'].forEach((sel) => $(sel)?.addEventListener('click', openAuthModal)); +['#btnOpenAuth2', '#btnOpenAuth3'].forEach((sel) => $(sel)?.addEventListener('click', () => openAuthModal('target'))); $('#btnCloseAuth').addEventListener('click', () => show($('#authModal'), false)); $('#authModal').addEventListener('click', (e) => { if (e.target.id === 'authModal') show($('#authModal'), false); }); @@ -7227,10 +7235,7 @@ function updateScopeAuthSummary() { : state.auth.header ? `Auth header set${roles ? ` · ${roles} role(s)` : ''}` : roles ? `${roles} role(s)` : 'Not set — agents test as an anonymous user.'; } -$('[data-open-authz]')?.addEventListener('click', () => { - openAuthModal(); - $('.modal-tab[data-mtab="authz"]')?.click(); -}); +$('[data-open-authz]')?.addEventListener('click', () => openAuthModal('authz')); $('#btnCloseAuth')?.addEventListener('click', updateScopeAuthSummary); // ---- new pentest entry points ---------------------------------------------- @@ -9495,7 +9500,7 @@ function applyModeFields() { $('.card-title', authCard).textContent = m.auth === 'infra' ? 'Domain or host credentials' : 'Authentication'; if (m.auth === 'infra') $('#scopeAuthSummary').textContent = state.credsPath ? `Using ${state.credsPath}` : 'None — add user/password, NTLM hash or SSH key in a creds file.'; else if (typeof updateScopeAuthSummary === 'function') updateScopeAuthSummary(); - authBtn.onclick = m.auth === 'infra' ? (e) => { e.stopImmediatePropagation(); openAuthModal(); $('.modal-tab[data-mtab="creds"]')?.click(); } : null; + authBtn.onclick = m.auth === 'infra' ? (e) => { e.stopImmediatePropagation(); openAuthModal('creds'); } : null; } // Launch: only the knobs that mean something for this kind of test. const web = ['run', 'greybox', 'aitest'].includes(state.mode);