61 lines
2.7 KiB
HTML
61 lines
2.7 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>Log in — rokojori</title>
|
||
|
|
<style>
|
||
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||
|
|
body { font-family: system-ui, sans-serif; background: #111; color: #eee; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
|
||
|
|
.card { background: #1c1c1c; border: 1px solid #2a2a2a; border-radius: 8px; padding: 2rem; width: 100%; max-width: 360px; }
|
||
|
|
h1 { font-size: 1.4rem; margin-bottom: 1.5rem; }
|
||
|
|
label { display: block; font-size: 0.85rem; color: #aaa; margin-bottom: 0.25rem; }
|
||
|
|
input { display: block; width: 100%; padding: 0.6rem 0.75rem; background: #111; border: 1px solid #333; border-radius: 4px; color: #eee; font-size: 0.95rem; margin-bottom: 1rem; }
|
||
|
|
input:focus { outline: none; border-color: #555; }
|
||
|
|
button { width: 100%; padding: 0.65rem; background: #2563eb; border: none; border-radius: 4px; color: #fff; font-size: 0.95rem; cursor: pointer; margin-top: 0.25rem; }
|
||
|
|
button:hover { background: #1d4ed8; }
|
||
|
|
.links { display: flex; justify-content: space-between; margin-top: 1.25rem; font-size: 0.8rem; }
|
||
|
|
.links a { color: #888; text-decoration: none; }
|
||
|
|
.links a:hover { color: #ccc; }
|
||
|
|
.error { color: #f87171; font-size: 0.85rem; margin-bottom: 0.75rem; }
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div class="card">
|
||
|
|
<h1>Log in</h1>
|
||
|
|
<form id="form">
|
||
|
|
<label for="email">Email</label>
|
||
|
|
<input type="email" id="email" name="email" required autocomplete="email">
|
||
|
|
<label for="password">Password</label>
|
||
|
|
<input type="password" id="password" name="password" required autocomplete="current-password">
|
||
|
|
<p class="error" id="error" hidden></p>
|
||
|
|
<button type="submit">Log in</button>
|
||
|
|
</form>
|
||
|
|
<div class="links">
|
||
|
|
<a href="/register.html">Create account</a>
|
||
|
|
<a href="/forgot-password.html">Forgot password?</a>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<script>
|
||
|
|
const redirect = new URLSearchParams(location.search).get('redirect') || '/profile.html';
|
||
|
|
document.getElementById('form').addEventListener('submit', async e => {
|
||
|
|
e.preventDefault();
|
||
|
|
const data = { email: e.target.email.value, password: e.target.password.value };
|
||
|
|
const res = await fetch('/api/auth/login', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify(data)
|
||
|
|
});
|
||
|
|
if (res.ok) {
|
||
|
|
location.href = redirect;
|
||
|
|
} else {
|
||
|
|
const err = await res.json();
|
||
|
|
const p = document.getElementById('error');
|
||
|
|
p.textContent = err.error;
|
||
|
|
p.hidden = false;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|