|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Panel Login</title> |
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> |
|
<style> |
|
body { |
|
display: flex; |
|
align-items: center; |
|
justify-content: center; |
|
min-height: 100vh; |
|
background-color: #f0f2f5; |
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
|
} |
|
.login-container { |
|
background-color: #ffffff; |
|
padding: 35px; |
|
border-radius: 10px; |
|
box-shadow: 0 5px 20px rgba(0,0,0,0.1); |
|
width: 100%; |
|
max-width: 420px; |
|
} |
|
.login-container h2 { |
|
margin-bottom: 25px; |
|
text-align: center; |
|
color: #333; |
|
font-weight: 600; |
|
} |
|
.form-control:focus { |
|
border-color: #0d6efd; |
|
box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25); |
|
} |
|
.btn-primary { |
|
background-color: #0d6efd; |
|
border-color: #0d6efd; |
|
transition: background-color 0.2s; |
|
} |
|
.btn-primary:hover { |
|
background-color: #0b5ed7; |
|
border-color: #0a58ca; |
|
} |
|
.alert { |
|
margin-top: 20px; |
|
font-size: 0.9rem; |
|
border-radius: 6px; |
|
} |
|
label { |
|
font-weight: 500; |
|
color: #555; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="login-container"> |
|
<h2>Panel Login</h2> |
|
<form id="loginForm"> |
|
<div class="mb-3"> |
|
<label for="username" class="form-label">Username</label> |
|
<input type="text" class="form-control" id="username" name="user" required> |
|
</div> |
|
<div class="mb-4"> |
|
<label for="password" class="form-label">Password</label> |
|
<input type="password" class="form-control" id="password" name="pass" required> |
|
</div> |
|
<button type="submit" class="btn btn-primary w-100 py-2">Login</button> |
|
</form> |
|
<div id="message" class="alert d-none mt-3" role="alert"></div> |
|
</div> |
|
|
|
<script> |
|
const loginForm = document.getElementById('loginForm'); |
|
const messageDiv = document.getElementById('message'); |
|
|
|
loginForm.addEventListener('submit', async (event) => { |
|
event.preventDefault(); |
|
messageDiv.classList.add('d-none'); |
|
messageDiv.textContent = ''; |
|
messageDiv.className = 'alert d-none mt-3'; |
|
|
|
const formData = new FormData(loginForm); |
|
const data = Object.fromEntries(formData.entries()); |
|
|
|
try { |
|
const response = await fetch('/private/server/exocore/web/panel', { |
|
method: 'POST', |
|
headers: { |
|
'Content-Type': 'application/json', |
|
}, |
|
body: JSON.stringify(data), |
|
}); |
|
|
|
const result = await response.json(); |
|
|
|
if (response.ok && result.status === 'success') { |
|
messageDiv.textContent = result.message || 'Login successful!'; |
|
messageDiv.classList.add('alert-success'); |
|
localStorage.setItem('panelLogin', 'success'); |
|
window.location.href = "/private/server/exocore/web/public/login" |
|
console.log('Login status saved to localStorage: panelLogin = success'); |
|
} else { |
|
messageDiv.textContent = result.message || `Login failed (Status: ${response.status})`; |
|
messageDiv.classList.add('alert-danger'); |
|
} |
|
} catch (error) { |
|
console.error('Login submission error:', error); |
|
messageDiv.textContent = 'An error occurred while trying to log in. Please check the console and try again.'; |
|
messageDiv.classList.add('alert-danger'); |
|
} |
|
messageDiv.classList.remove('d-none'); |
|
}); |
|
</script> |
|
</body> |
|
</html> |
|
|