Files
DarkflameServer/dDashboardServer/static/js/login.js
Aaron Kimbrell e3467465b4 Add dashboard audit log and configuration management
- Implemented dashboard audit logging with InsertAuditLog, GetRecentAuditLogs, GetAuditLogsByIP, and CleanupOldAuditLogs methods.
- Created dashboard configuration management with GetDashboardConfig and SetDashboardConfig methods.
- Added new tables for dashboard_audit_log and dashboard_config in both MySQL and SQLite migrations.
- Updated CMakeLists to include Crow and ASIO for dashboard server functionality.
- Enhanced existing database classes to support new dashboard features, including character, play key, and property management.
- Added new methods for retrieving and managing play keys, properties, and pet names.
- Updated TestSQLDatabase to include stubs for new dashboard-related methods.
- Modified shared and dashboard configuration files for new settings.
2026-04-22 11:01:41 -05:00

47 lines
1.5 KiB
JavaScript

/**
* Login page functionality
*/
// Function to initialize login form
function initLoginForm() {
const form = document.getElementById('login-form');
if (!form) return; // Not on login page
form.addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const messageDiv = document.getElementById('login-message');
try {
const response = await API.post('/api/login', { username, password });
if (response && response.success) {
messageDiv.className = 'alert alert-success';
messageDiv.textContent = 'Login successful! Redirecting...';
messageDiv.style.display = 'block';
setTimeout(() => {
window.location.href = '/';
}, 1000);
} else {
messageDiv.className = 'alert alert-danger';
messageDiv.textContent = response.error || 'Login failed';
messageDiv.style.display = 'block';
}
} catch (error) {
messageDiv.className = 'alert alert-danger';
messageDiv.textContent = error.message || 'An error occurred during login';
messageDiv.style.display = 'block';
}
});
}
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initLoginForm);
} else {
initLoginForm();
}