93 lines
2.3 KiB
HTML
93 lines
2.3 KiB
HTML
{{ define "admin/login.html" }}
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Simple Login Page</title>
|
|
<style>
|
|
body {
|
|
font-family: sans-serif;
|
|
background-color: #f0f0f0;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
}
|
|
.login-container {
|
|
background-color: #fff;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
text-align: center;
|
|
}
|
|
input[type="password"] {
|
|
padding: 10px;
|
|
margin: 10px 0;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
width: 200px;
|
|
}
|
|
button {
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
padding: 10px 15px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background-color: #3e8e41;
|
|
}
|
|
#message {
|
|
margin-top: 10px;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="login-container">
|
|
<h2>Login</h2>
|
|
<input type="password" id="password" placeholder="Password"><br>
|
|
<button onclick="login()">Login</button>
|
|
<div id="message"></div>
|
|
</div>
|
|
|
|
<script>
|
|
function login() {
|
|
const password = document.getElementById('password').value;
|
|
|
|
fetch('api/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ "Password": password })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.message === "Login successful") {
|
|
document.getElementById('message').innerText = data.message;
|
|
saveToken(data.token);
|
|
setTimeout(() => {
|
|
window.location.href = "/";
|
|
}, 1000);
|
|
} else {
|
|
document.getElementById('message').innerText = "Login failed.";
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
document.getElementById('message').innerText = "An error occurred.";
|
|
});
|
|
}
|
|
|
|
function saveToken(token) {
|
|
document.cookie = "token=" + token + "; path=/";
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
{{ end }}
|