fix: Actually trigger WebAuthn authentication
**Motivations :** - Fix misleading 'Authentication completed successfully' message - Ensure WebAuthn is actually triggered, not just pairing process - Provide accurate status messages for WebAuthn operations **Modifications :** - Import secureCredentialsService directly in handleMainPairing - Check for existing credentials and trigger appropriate WebAuthn flow - Separate status messages for credential decryption vs creation - Only show success message after actual WebAuthn completion **Pages affectées :** - src/pages/home/home.ts - Fixed WebAuthn triggering logic
This commit is contained in:
parent
65132ea2f0
commit
1d711932ce
@ -558,13 +558,41 @@ async function handleMainPairing(): Promise<void> {
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<div class="spinner"></div><span>Authenticating with browser...</span>';
|
||||
}
|
||||
|
||||
// This will trigger the WebAuthn flow and create/decrypt credentials
|
||||
await prepareAndSendPairingTx();
|
||||
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ Authentication completed successfully</span>';
|
||||
|
||||
// Import and trigger WebAuthn directly
|
||||
const { secureCredentialsService } = await import('../../services/secure-credentials.service');
|
||||
|
||||
// Check if we have existing credentials
|
||||
const hasCredentials = await secureCredentialsService.hasCredentials();
|
||||
|
||||
if (hasCredentials) {
|
||||
console.log('🔓 Existing credentials found, decrypting...');
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<div class="spinner"></div><span>Decrypting existing credentials...</span>';
|
||||
}
|
||||
|
||||
// This will trigger WebAuthn for decryption
|
||||
await secureCredentialsService.retrieveCredentials('');
|
||||
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ Credentials decrypted successfully</span>';
|
||||
}
|
||||
} else {
|
||||
console.log('🔐 No existing credentials, creating new ones...');
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<div class="spinner"></div><span>Creating new credentials...</span>';
|
||||
}
|
||||
|
||||
// This will trigger WebAuthn for creation
|
||||
await secureCredentialsService.generateSecureCredentials('');
|
||||
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<span style="color: var(--success-color)">✅ New credentials created successfully</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Now proceed with pairing process
|
||||
await prepareAndSendPairingTx();
|
||||
|
||||
// Re-enable button
|
||||
if (mainPairingButton) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user