fix: include auth.js in dashboard overhaul

This commit is contained in:
2026-02-26 15:40:17 -05:00
parent 686163780c
commit b52e0e3af0

View File

@@ -55,42 +55,33 @@ class AuthManager {
const loginBtn = document.querySelector('.login-btn');
try {
// Show loading state
loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Authenticating...';
loginBtn.disabled = true;
// Simple authentication - in production, this would call an API
// For now, using mock authentication
await new Promise(resolve => setTimeout(resolve, 1000));
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
});
if (username === 'admin' && password === 'admin123') {
// Successful login
this.token = this.generateToken();
this.user = {
username: 'admin',
name: 'Administrator',
role: 'Super Admin',
avatar: null
};
const result = await response.json();
if (result.success) {
this.token = result.data.token;
this.user = result.data.user;
// Save to localStorage
localStorage.setItem('dashboard_token', this.token);
localStorage.setItem('dashboard_user', JSON.stringify(this.user));
this.isAuthenticated = true;
this.showDashboard();
// Show success message
this.showToast('Successfully logged in!', 'success');
} else {
throw new Error('Invalid credentials');
throw new Error(result.error || 'Invalid credentials');
}
} catch (error) {
// Show error
errorElement.style.display = 'flex';
errorElement.querySelector('span').textContent = error.message;
// Reset button
loginBtn.innerHTML = '<i class="fas fa-sign-in-alt"></i> Sign In';
loginBtn.disabled = false;
}