cs2-rcon-panel/views/login.ejs
2023-09-28 10:53:33 +05:30

166 lines
3.9 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<!-- Include Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<style>
body {
background: linear-gradient(to bottom right, #3494E6, #EC6EAD);
color: #fff;
height: 100vh;
}
.card {
border: none;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
background-color: #fff;
}
.card-header {
background-color: #007BFF;
color: #fff;
}
.card-title {
font-size: 24px;
}
.form-control {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
}
.btn-primary {
background-color: #007BFF;
border: none;
}
.btn-primary:hover {
background-color: #0056b3;
}
.btn-secondary {
background-color: #6c757d;
border: none;
}
.btn-secondary:hover {
background-color: #5a6268;
}
.toast {
background-color: #28a745;
color: #fff;
}
/* Custom styling for form elements */
.form-container {
margin-top: 20px;
}
.form-label {
font-weight: bold;
}
.btn-container {
margin-top: 20px;
}
/* Responsive styling for small screens */
@media (max-width: 576px) {
.form-container {
margin-top: 10px;
}
.btn-container {
margin-top: 10px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 offset-md-3 form-container">
<div class="card">
<div class="card-header">
<h3 class="card-title">Login</h3>
</div>
<div class="card-body">
<form>
<div class="mb-3">
<label for="username" class="form-label">Username:</label>
<input type="text" id="username" class="form-control" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password:</label>
<input type="password" id="password" class="form-control" required>
</div>
<div class="btn-container">
<button id="login_btn" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-secondary">Reset</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Include Bootstrap JS and jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
// Event listener for the submit button
$('#login_btn').on('click', function (e) {
e.preventDefault(); // Prevent the default form submission
// Get input values
const username = $('#username').val();
const password = $('#password').val();
if (!username || !password) {
alert('All fields are required.');
return;
}
// Create server data object
const user_data = {
username,
password,
};
// Make an API POST request to add the server
$.ajax({
url: '/auth/login', // Adjust the API endpoint
type: 'POST',
data: JSON.stringify(user_data),
contentType: 'application/json',
success: function (data) {
if (data.status == 200) {
window.location = "/servers";
} else if (data.status == 401) {
alert('Invalid Credentials')
}
},
error: function (error) {
console.error(error);
alert('Login Failed');
},
});
});
});
</script>
</body>
</html>