109 lines
2.2 KiB
HTML
109 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login - openplace</title>
|
|
<style>
|
|
body {
|
|
font-family: sans-serif;
|
|
max-width: 400px;
|
|
margin: 100px auto;
|
|
padding: 20px;
|
|
background-color: #f5f5f5;
|
|
}
|
|
.login-form {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 10%;
|
|
box-shadow: 0 20px 50px rgba(0,0,0,0.1);
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
color: #333;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
font-weight: bold;
|
|
color: #555;
|
|
}
|
|
input[type="text"], input[type="password"] {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background-color: #0069ff;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 10px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
.error {
|
|
color: red;
|
|
margin-top: 10px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-form">
|
|
<h1>Welcome back!</h1>
|
|
<form id="loginForm">
|
|
<div class="form-group">
|
|
<input type="text" id="username" name="username" placeholder="Username" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<input type="password" id="password" name="password" placeholder="Password" required>
|
|
</div>
|
|
<button type="submit">Login</button>
|
|
<div id="error" class="error"></div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById("loginForm").addEventListener("submit", async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById("username").value;
|
|
const password = document.getElementById("password").value;
|
|
const errorDiv = document.getElementById("error");
|
|
|
|
try {
|
|
const response = await fetch("/login", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ username, password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
window.location.href = "/";
|
|
} else {
|
|
errorDiv.textContent = data.error || "Login failed";
|
|
}
|
|
} catch (error) {
|
|
errorDiv.textContent = "Network error occurred";
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|