35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
const btn = document.getElementById('loginBtn');
|
|
const loader = document.getElementById('loadingIndicator');
|
|
const status = document.getElementById('statusMessage');
|
|
|
|
if (btn) {
|
|
btn.addEventListener('click', async () => {
|
|
loader.style.display = 'block';
|
|
btn.disabled = true;
|
|
status.textContent = '';
|
|
status.className = '';
|
|
|
|
try {
|
|
const username = document.getElementById('loginUsername')?.value?.trim() || '';
|
|
await startWebAuthnLogin(username);
|
|
} catch (_e) {
|
|
// handled in auth-client.js
|
|
} finally {
|
|
loader.style.display = 'none';
|
|
btn.disabled = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
// Initialize WebAuthn Conditional UI (Autofill) if supported
|
|
if (globalThis.PublicKeyCredential && PublicKeyCredential.isConditionalMediationAvailable) {
|
|
PublicKeyCredential.isConditionalMediationAvailable().then(available => {
|
|
if (available) {
|
|
console.log("[WebAuthn] Conditional mediation autofill available");
|
|
if (typeof startWebAuthnConditionalLogin === "function") {
|
|
startWebAuthnConditionalLogin();
|
|
}
|
|
}
|
|
}).catch(() => {});
|
|
}
|