Welcome to your Client Portal
Please login to your Client Portal to be able to view your documents
}
async function authenticate() {
const username = document.getElementById('username').value;
if (!username) return alert('Enter a username');
const status = document.getElementById('status');
status.textContent = 'Authenticating...';
// Get options from server
const response = await fetch(`${BASE_URL}/auth`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username }),
});
const options = await response.json();
// Use WebAuthn to get assertion (triggers biometric)
const assertion = await navigator.credentials.get({ publicKey: options });
status.textContent = 'Verifying...';
// Verify with server
const verifyResponse = await fetch(`${BASE_URL}/auth/verify`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, response: assertion.response }),
});
const result = await verifyResponse.json();
status.textContent = result.success ? `Welcome, ${result.user}!` : 'Failed';
}
</script>
</body>
</html>