diff --git a/static/app.js b/static/app.js index 6b3167b..fec3668 100644 --- a/static/app.js +++ b/static/app.js @@ -84,19 +84,21 @@ function showDeviceAdditionView() { } } -function showDashboardView() { +async function showDashboardView() { if (window.location.pathname !== '/auth/profile') { window.location.href = '/auth/profile' return } showView('profileView') clearStatus('profileStatus') - loadUserInfo().then(() => { + + try { + await loadUserInfo() updateUserInfo() - loadCredentials() - }).catch(error => { + await loadCredentials() + } catch (error) { showStatus('profileStatus', `Failed to load user info: ${error.message}`, 'error') - }) + } } // ======================================== diff --git a/static/dashboard.html b/static/dashboard.html deleted file mode 100644 index 51fef62..0000000 --- a/static/dashboard.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - Dashboard - Passkey Authentication - - - - - - -
- -
-

👋 Welcome!

- -
- -

Your Passkeys

-
-

Loading credentials...

-
- - - - - - - -
-
- - - - - diff --git a/static/profile.html b/static/profile.html index 30e5b96..8b5c949 100644 --- a/static/profile.html +++ b/static/profile.html @@ -3,69 +3,10 @@ Profile - Passkey Authentication + -
@@ -122,90 +63,6 @@
- + diff --git a/static/profile.js b/static/profile.js index fe0251c..9325362 100644 --- a/static/profile.js +++ b/static/profile.js @@ -3,7 +3,7 @@ document.addEventListener('DOMContentLoaded', function() { // Initialize the app initializeApp() - + // Setup dialog event handlers setupDialogHandlers() }) @@ -19,7 +19,7 @@ function setupDialogHandlers() { } }) } - + // Close dialog when pressing Escape key document.addEventListener('keydown', function(e) { const dialog = document.getElementById('deviceLinkDialog') @@ -34,12 +34,12 @@ function openDeviceLinkDialog() { const dialog = document.getElementById('deviceLinkDialog') const container = document.querySelector('.container') const body = document.body - + if (dialog && container && body) { // Add blur and disable effects container.classList.add('dialog-open') body.classList.add('dialog-open') - + dialog.showModal() generateDeviceLink() } @@ -50,12 +50,12 @@ function closeDeviceLinkDialog() { const dialog = document.getElementById('deviceLinkDialog') const container = document.querySelector('.container') const body = document.body - + if (dialog && container && body) { // Remove blur and disable effects container.classList.remove('dialog-open') body.classList.remove('dialog-open') - + dialog.close() } } @@ -64,7 +64,7 @@ function closeDeviceLinkDialog() { function generateDeviceLink() { clearStatus('deviceAdditionStatus') showStatus('deviceAdditionStatus', 'Generating device link...', 'info') - + fetch('/api/create-device-link', { method: 'POST', credentials: 'include' @@ -72,22 +72,22 @@ function generateDeviceLink() { .then(response => response.json()) .then(result => { if (result.error) throw new Error(result.error) - + // Update UI with the link const deviceLinkText = document.getElementById('deviceLinkText') const deviceToken = document.getElementById('deviceToken') - + if (deviceLinkText) { deviceLinkText.textContent = result.addition_link } - + if (deviceToken) { deviceToken.textContent = result.token } - + // Store link globally for copy function window.currentDeviceLink = result.addition_link - + // Generate QR code const qrCodeEl = document.getElementById('qrCode') if (qrCodeEl && typeof QRCode !== 'undefined') { @@ -97,9 +97,12 @@ function generateDeviceLink() { width: 200, height: 200, colorDark: '#000000', - colorLight: '#ffffff' + colorLight: '#ffffff', + correctLevel: QRCode.CorrectLevel.M }) } + + clearStatus('deviceAdditionStatus') }) .catch(error => { showStatus('deviceAdditionStatus', `Failed to generate device link: ${error.message}`, 'error') diff --git a/static/util.js b/static/util.js index da1b8f9..536aca5 100644 --- a/static/util.js +++ b/static/util.js @@ -40,12 +40,13 @@ async function checkExistingSession() { } else if (protectedRoutes.includes(path)) { // Stay on current protected page and load user data if (path === '/auth/profile') { - loadUserInfo().then(() => { + try { + await loadUserInfo() updateUserInfo() - loadCredentials() - }).catch(error => { + await loadCredentials() + } catch (error) { showStatus('profileStatus', `Failed to load user info: ${error.message}`, 'error') - }) + } } } } else {