Files
momentry_core/docs_v1.0/doc_developer/login.html

59 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login - Momentry Docs</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; display: flex; justify-content: center; align-items: center; height: 100vh; }
.card { background: white; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 40px; width: 360px; }
h1 { font-size: 24px; margin-bottom: 24px; text-align: center; }
input { width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
button { width: 100%; padding: 10px; background: #0066cc; color: white; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; }
button:hover { background: #0052a3; }
.btn-logout { background: #888; margin-top: 8px; font-size: 13px; padding: 6px; }
.btn-logout:hover { background: #666; }
.error { color: #cc0000; font-size: 13px; margin-bottom: 12px; display: none; }
.success { color: #006600; font-size: 13px; margin-bottom: 12px; display: none; }
</style>
</head>
<body>
<div class="card">
<h1>Momentry Docs</h1>
<form id="loginForm">
<input type="text" id="username" placeholder="Username" value="demo" required>
<input type="password" id="password" placeholder="Password" value="" required>
<div class="error" id="error">Invalid credentials</div>
<button type="submit">Login</button>
<button type="button" class="btn-logout" onclick="logout()">Logout (clear session)</button>
<div class="success" id="logoutMsg">Session cleared</div>
</form>
</div>
<script>
document.getElementById('loginForm').onsubmit = async function(e) {
e.preventDefault();
const resp = await fetch('/api/v1/auth/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
username: document.getElementById('username').value,
password: document.getElementById('password').value
})
});
if (resp.ok) {
window.location.href = '/doc/index.html';
} else {
document.getElementById('error').style.display = 'block';
}
};
async function logout() {
const resp = await fetch('/api/v1/auth/logout', { method: 'POST' });
if (resp.ok) {
document.getElementById('logoutMsg').style.display = 'block';
document.getElementById('error').style.display = 'none';
setTimeout(() => window.location.reload(), 1000);
}
};
</script>
</body>
</html>