fix(web): authentication button always opens the Target login tab

- reset the Auth & Keys tab on every open instead of keeping the last one
- Authentication -> Target login, rules -> Scope, infra creds -> Files
This commit is contained in:
CyberSecurityUP committed 2026-12-03 09:23:06 -03:00
1 parent e66ba3c1aa
commit 53cef9e5a9
1 file changed
+12 -7
+12 -7
View File
@@ -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);