Skip to content

Login & Register

n/json', }, body: JSON.stringify({ type: 1, // Fixed as email type username: email, code: verificationCode, password: password, confirm_password: confirmPassword }) }) .then(response => response.json()) .then(data => { console.log("Reset password response", data); if (data.code==2000) { showMessage('Password reset successful! Please login with your new password', 'success'); resetResetCountdown(); // Delay switch to login tab setTimeout(() => { switchTab('login'); // Clear reset form resetForm.reset(); }, 1500); } else { showMessage(data.msg || 'Password reset failed, please check your input!', 'error'); } }) .catch(error => { console.error('Error:', error); showMessage('Password reset request failed, please try again later!', 'error'); }) .finally(() => { // Restore button state submitBtn.textContent = originalText; submitBtn.disabled = false; }); } // Check login status when page loads document.addEventListener('DOMContentLoaded', async function() { const isLoggedIn = await validateToken(); if (isLoggedIn) { showMessage('You are already logged in, redirecting to homepage...', 'info'); setTimeout(() => { window.location.href = '/'; }, 2000); } }); })(); // End of immediately invoked function