Skip to content

Commit 6edb43b

Browse files
Suppress zxcvbn feedback until hard requirements are met
While the requirements checklist is visible (e.g. password < 15 chars), hide zxcvbn warning and suggestions they duplicate the same guidance. Once all requirements pass and the checklist hides, zxcvbn feedback resumes normally to provide qualitative strength guidance.
1 parent 5fe0bb6 commit 6edb43b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

EssentialCSharp.Web/wwwroot/js/password-strength.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,21 @@ function updateMeter(container, score, feedback, crackTimesDisplay) {
9191

9292
label.textContent = config.label;
9393

94+
// Suppress zxcvbn feedback while hard requirements (e.g. minimum length) are still unmet —
95+
// the requirements checklist already tells the user what to fix; showing both is redundant.
96+
const requirementsList = container.querySelector('.password-requirements');
97+
const requirementsPending = requirementsList && !requirementsList.classList.contains('d-none');
98+
9499
// Warning: what's wrong (null for score >= 3)
95100
if (warningEl) {
96-
warningEl.textContent = feedback.warning ?? '';
97-
warningEl.classList.toggle('d-none', !feedback.warning);
101+
const warning = requirementsPending ? '' : (feedback.warning ?? '');
102+
warningEl.textContent = warning;
103+
warningEl.classList.toggle('d-none', !warning);
98104
}
99105

100106
// Suggestions: how to improve
101107
if (suggestionsEl) {
102-
const tips = (feedback.suggestions ?? []).filter(Boolean);
108+
const tips = requirementsPending ? [] : (feedback.suggestions ?? []).filter(Boolean);
103109
suggestionsEl.textContent = tips.join(' ');
104110
suggestionsEl.classList.toggle('d-none', tips.length === 0);
105111
}

0 commit comments

Comments
 (0)