| 6776 | } |
| 6777 | |
| 6778 | function toggleRecoveryPanel(show) { |
| 6779 | var panel = document.getElementById('recoveryPanel'); |
| 6780 | if (panel) panel.classList.toggle('hidden', !show); |
| 6781 | if (show) populateRecoveryQuestions(); |
| 6782 | } |
| 6783 | |
| 6784 | async function submitLogin() { |
| 6785 | var input = document.getElementById('loginPasswordInput'); |
| 6786 | var otpInput = document.getElementById('loginOtpInput'); |
| 6787 | try { |
| 6788 | await apiPost('/api/auth/login', { username: document.getElementById('loginUsernameInput').value.trim(), password: input ? input.value : '', otp: otpInput ? otpInput.value : '' }); |
| 6789 | state.authenticated = true; |
| 6790 | state.authRequired = false; |
| 6791 | hideLoginOverlay(); |
| 6792 | await bootApp(); |
| 6793 | } catch (err) { |
| 6794 | showToast(err.message || t('Wrong password'), true); |
| 6795 | if (input) { input.value = ''; input.focus(); } |
| 6796 | if (otpInput) otpInput.value = ''; |
| 6797 | } |