(endpoint)
| 11605 | </button> |
| 11606 | <button onclick="loadSecurityConfig()" |
| 11607 | class="bg-slate-600 hover:bg-slate-700 text-white px-4 py-2 rounded-lg transition-colors text-sm"> |
| 11608 | Done |
| 11609 | </button> |
| 11610 | </div> |
| 11611 | `; |
| 11612 | |
| 11613 | // Store codes temporarily for copy function |
| 11614 | window._tempRecoveryCodes = result.recovery_codes; |
| 11615 | |
| 11616 | addConsoleMessage('Authentication enabled - database encrypted', 'success'); |
| 11617 | } else { |
| 11618 | statusEl.className = 'p-3 rounded-lg text-sm bg-red-900/30 border border-red-700 text-red-300'; |
| 11619 | statusEl.textContent = result.error || 'Setup failed'; |
| 11620 | statusEl.classList.remove('hidden'); |
| 11621 | btn.disabled = false; |
| 11622 | btn.textContent = 'Enable Authentication'; |
| 11623 | } |
| 11624 | } catch (error) { |
| 11625 | statusEl.className = 'p-3 rounded-lg text-sm bg-red-900/30 border border-red-700 text-red-300'; |
| 11626 | statusEl.textContent = 'Setup failed: ' + (error.message || 'Unknown error'); |
| 11627 | statusEl.classList.remove('hidden'); |
| 11628 | btn.disabled = false; |
| 11629 | btn.textContent = 'Enable Authentication'; |
| 11630 | } |
| 11631 | } |
| 11632 | |
| 11633 | function copyRecoveryCodes() { |
| 11634 | if (window._tempRecoveryCodes) { |
| 11635 | const text = window._tempRecoveryCodes.join('\n'); |
| 11636 | navigator.clipboard.writeText(text).then(() => { |
| 11637 | const btn = document.getElementById('copy-codes-btn'); |
| 11638 | btn.textContent = 'Copied!'; |
| 11639 | setTimeout(() => { btn.textContent = 'Copy All Codes'; }, 2000); |
| 11640 | }).catch(() => { |
| 11641 | addConsoleMessage('Failed to copy - please select and copy manually', 'warning'); |
| 11642 | }); |
| 11643 | } |
| 11644 | } |
| 11645 | |
| 11646 | async function handleChangePassword(event) { |
| 11647 | event.preventDefault(); |
| 11648 | const statusEl = document.getElementById('change-pw-status'); |
| 11649 | |
| 11650 | const currentPw = document.getElementById('current-password').value; |
| 11651 | const newPw = document.getElementById('new-password').value; |
| 11652 | const confirmPw = document.getElementById('confirm-new-password').value; |
| 11653 | |
| 11654 | if (newPw !== confirmPw) { |
| 11655 | statusEl.className = 'p-3 rounded-lg text-sm bg-red-900/30 border border-red-700 text-red-300'; |
| 11656 | statusEl.textContent = 'New passwords do not match'; |
| 11657 | statusEl.classList.remove('hidden'); |
| 11658 | return; |
| 11659 | } |
| 11660 |
no test coverage detected