From ef479948e246e99e405a79b166d131bc4ab29b29 Mon Sep 17 00:00:00 2001 From: Matthew Badeau Date: Sun, 13 Jul 2025 11:07:01 +0900 Subject: [PATCH] Present password feedback directly to user --- app/javascript/controllers/zxcvbn_controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/zxcvbn_controller.ts b/app/javascript/controllers/zxcvbn_controller.ts index 38c2dd1ef..89a30f362 100644 --- a/app/javascript/controllers/zxcvbn_controller.ts +++ b/app/javascript/controllers/zxcvbn_controller.ts @@ -30,7 +30,10 @@ export default class extends Controller { const widths = ['w-0', 'w-25', 'w-50', 'w-75', 'w-100'] const severities = ['bg-danger', 'bg-danger', 'bg-danger', 'bg-warning', 'bg-success', 'bg-success', 'bg-success', 'bg-success', 'bg-success'].slice(4 - this.minScore, 4 - this.minScore + 5) const result = zxcvbn(this.value()) - if (this.meter != null) { this.meter.className = `progress-bar zxcvbn-meter ${widths[result.score]} ${severities[result.score]}` } + if (this.meter != null) { + this.meter.className = `progress-bar zxcvbn-meter ${widths[result.score]} ${severities[result.score]}` + this.meter.textContent = String(result.feedback.warning ?? '') + } } }