fix: Always trigger WebAuthn authentication

**Motivations :**
- Restore previous WebAuthn behavior that was lost in interface simplification
- Ensure WebAuthn is always triggered regardless of existing credentials
- Maintain consistent authentication flow

**Modifications :**
- Removed conditional logic that prevented WebAuthn from triggering
- Always call prepareAndSendPairingTx() which triggers WebAuthn
- Simplified authentication flow to always require user interaction

**Pages affectées :**
- src/pages/home/home.ts - Fixed WebAuthn triggering logic
This commit is contained in:
NicolasCantu 2025-10-23 20:40:41 +02:00
parent 050351d52e
commit 8261e0533d
2 changed files with 13 additions and 32 deletions

View File

@ -549,36 +549,17 @@ async function handleMainPairing(): Promise<void> {
mainPairingButton.textContent = 'Authenticating...';
}
// Check if we have existing credentials
const service = await Services.getInstance();
const { secureCredentialsService } = await import('../../services/secure-credentials.service');
const hasCredentials = await secureCredentialsService.hasCredentials();
if (hasCredentials) {
// Existing pairing - decrypt credentials
console.log('🔓 Existing credentials found, decrypting...');
// Always trigger WebAuthn flow for authentication
console.log('🔐 Triggering WebAuthn authentication...');
if (mainStatus) {
mainStatus.innerHTML = '<div class="spinner"></div><span>Decrypting existing credentials...</span>';
mainStatus.innerHTML = '<div class="spinner"></div><span>Authenticating with browser...</span>';
}
await secureCredentialsService.retrieveCredentials(''); // Empty password for WebAuthn
if (mainStatus) {
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ Credentials decrypted successfully</span>';
}
} else {
// No existing pairing - create new one
console.log('🔐 No existing credentials, creating new pairing...');
if (mainStatus) {
mainStatus.innerHTML = '<div class="spinner"></div><span>Creating new secure pairing...</span>';
}
// This will trigger the WebAuthn flow and create new credentials
// This will trigger the WebAuthn flow and create/decrypt credentials
await prepareAndSendPairingTx();
if (mainStatus) {
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ New pairing created successfully</span>';
}
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ Authentication completed successfully</span>';
}
// Re-enable button