|
26 | 26 | const redirectUrl = urlParams.get('redirect') |
27 | 27 | const fileId = urlParams.get('fileId') |
28 | 28 | const from = urlParams.get('from') |
| 29 | + const errorModal = document.getElementById('error_modal') |
| 30 | + const errorMessageElement = document.getElementById('error_modal_message') |
| 31 | + const ignoreBtn = document.getElementById('ignore_and_continue_btn') |
29 | 32 |
|
30 | 33 | try { |
31 | | - const encryptedData = await receiveAndValidateEncryptedCredentials(fileId, from, hashParams, uuid) |
32 | 34 | const instanceId = uuid.split('-')[0] |
33 | | - if (encryptedData) { // save |
| 35 | + if (fileId || from) try { // save |
| 36 | + const encryptedData = await receiveAndValidateEncryptedCredentials(fileId, from, hashParams, uuid) |
34 | 37 | localStorage.setItem(`fount-login-${instanceId}`, encryptedData) |
35 | 38 | window.location.href = decodeURIComponent(redirectUrl) |
| 39 | + } catch (error) { |
| 40 | + console.error('Failed to receive credentials:', error) |
| 41 | + errorMessageElement.textContent = `An error occurred while trying to retrieve your login credentials: ${error.message}\nYou can continue without logging in.` |
| 42 | + throw error |
36 | 43 | } |
37 | | - else // load |
| 44 | + else try {// load |
38 | 45 | await transferEncryptedCredentials(uuid, redirectUrl) |
| 46 | + } catch (error) { |
| 47 | + console.error('Failed to transfer credentials:', error) |
| 48 | + errorMessageElement.textContent = `An error occurred while trying to transfer your login credentials: ${error.message}\nYou can continue without login info.` |
| 49 | + throw error |
| 50 | + } |
39 | 51 | } |
40 | 52 | catch (error) { |
41 | | - console.error('Failed to receive credentials:', error) |
42 | | - const errorModal = document.getElementById('error_modal') |
43 | | - const errorMessageElement = document.getElementById('error_modal_message') |
44 | | - const ignoreBtn = document.getElementById('ignore_and_continue_btn') |
45 | | - |
46 | | - errorMessageElement.textContent = `An error occurred while trying to retrieve your login credentials: ${error.message}. You can continue without logging in.` |
47 | 53 | errorModal.showModal() |
48 | 54 |
|
49 | 55 | ignoreBtn.onclick = () => { |
|
0 commit comments