Skip to content

Commit 0c1f810

Browse files
committed
Fix passkey label overflow and add rename length validation
- Validate 64-char max on rename before sending to backend - Truncate long labels with ellipsis instead of breaking layout - Prevent buttons from being pushed off-screen by long names
1 parent 1c99a9a commit 0c1f810

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function displayCredentials(container, credentials) {
4747
container.innerHTML = credentials.map(cred => `
4848
<div class="card mb-2" data-id="${escapeHtml(cred.id)}">
4949
<div class="card-body d-flex justify-content-between align-items-center py-2">
50-
<div>
51-
<strong>${escapeHtml(cred.label || 'Unnamed Passkey')}</strong>
50+
<div class="me-3" style="min-width: 0;">
51+
<strong class="d-inline-block text-truncate" style="max-width: 100%;">${escapeHtml(cred.label || 'Unnamed Passkey')}</strong>
5252
<br>
5353
<small class="text-muted">
5454
Created: ${new Date(cred.created).toLocaleDateString()}
@@ -59,7 +59,7 @@ function displayCredentials(container, credentials) {
5959
? '<span class="badge bg-success">Synced</span>'
6060
: '<span class="badge bg-warning text-dark">Device-bound</span>'}
6161
</div>
62-
<div>
62+
<div class="flex-shrink-0">
6363
<button class="btn btn-sm btn-outline-secondary me-1" onclick="window.renamePasskey('${escapeHtml(cred.id)}')">
6464
<i class="bi bi-pencil"></i> Rename
6565
</button>
@@ -76,9 +76,17 @@ function displayCredentials(container, credentials) {
7676
* Rename a passkey.
7777
*/
7878
async function renamePasskey(credentialId) {
79-
const newLabel = prompt('Enter new name for this passkey:');
79+
const newLabel = prompt('Enter new name for this passkey (max 64 characters):');
8080
if (!newLabel) return;
8181

82+
if (newLabel.length > 64) {
83+
const globalMsg = document.getElementById('passkeyMessage');
84+
if (globalMsg) {
85+
showMessage(globalMsg, 'Passkey name is too long (max 64 characters).', 'alert-danger');
86+
}
87+
return;
88+
}
89+
8290
const globalMessage = document.getElementById('passkeyMessage');
8391

8492
try {

0 commit comments

Comments
 (0)