(function() { function showError(message) { var errorElement = document.getElementById('login-error'); errorElement.style.display = 'block'; errorElement.textContent = message; } function hideError() { var errorElement = document.getElementById('login-error'); errorElement.style.display = 'none'; } document.addEventListener('DOMContentLoaded', function() { window.CrankAuth.guardLoginPage().catch(function(error) { console.error(error); }); document.getElementById('login-form').addEventListener('submit', async function(event) { event.preventDefault(); var email = document.getElementById('email').value.trim(); var password = document.getElementById('password').value; if (!email || !password) { showError('Please enter your email and password.'); return; } hideError(); try { await window.CrankAuth.login(email, password); } catch (error) { if (error && error.status === 401) { showError('Invalid email or password. Please try again.'); return; } showError('Unable to sign in right now. Please try again.'); } }); }); }());