Skip to content

Commit 43d2b41

Browse files
committed
fix: address PR review feedback for passwordless UI
- Escape auth.provider in HTML to prevent XSS (A1) - Add aria-label to remove-password confirm input (A2) - Show user-facing error when auth methods fail to load (A3)
1 parent 16a0fa1 commit 43d2b41

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/resources/static/js/user/webauthn-manage.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ async function updateAuthMethodsUI() {
283283
badges += `<span class="badge bg-success me-2"><i class="bi bi-key me-1"></i>Passkeys (${auth.passkeysCount})</span>`;
284284
}
285285
if (auth.provider && auth.provider !== 'LOCAL') {
286-
badges += `<span class="badge bg-info me-2"><i class="bi bi-cloud me-1"></i>${auth.provider}</span>`;
286+
badges += `<span class="badge bg-info me-2"><i class="bi bi-cloud me-1"></i>${escapeHtml(auth.provider)}</span>`;
287287
}
288288
badgesContainer.innerHTML = badges;
289289

@@ -306,6 +306,10 @@ async function updateAuthMethodsUI() {
306306
}
307307
} catch (error) {
308308
console.error('Failed to update auth methods UI:', error);
309+
const section = document.getElementById('auth-methods-section');
310+
if (section) {
311+
section.innerHTML = '<div class="alert alert-warning">Unable to load authentication methods.</div>';
312+
}
309313
}
310314
}
311315

src/main/resources/templates/user/update-user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ <h5 class="modal-title" id="removePasswordModalLabel"><i class="bi bi-exclamatio
7878
<div class="modal-body">
7979
<p>You are about to remove your password. After this, you will only be able to sign in using your passkeys.</p>
8080
<p class="mb-2"><strong>Type REMOVE to confirm:</strong></p>
81-
<input type="text" id="removePasswordConfirmInput" class="form-control" placeholder="Type REMOVE">
81+
<input type="text" id="removePasswordConfirmInput" class="form-control" placeholder="Type REMOVE" aria-label="Type REMOVE to confirm">
8282
<div id="removePasswordError" class="form-text text-danger d-none mt-1"></div>
8383
</div>
8484
<div class="modal-footer">

0 commit comments

Comments
 (0)