72 lines
2.8 KiB
Plaintext
72 lines
2.8 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>Initial Setup - RSS Reader</title>
|
||
|
<link rel="stylesheet" href="/static/css/style.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="setup-container">
|
||
|
<h1>Welcome to RSS Reader</h1>
|
||
|
<p>Please create your initial admin user account.</p>
|
||
|
|
||
|
<form id="setupForm" class="setup-form">
|
||
|
<div class="form-group">
|
||
|
<label for="username">Username</label>
|
||
|
<input type="text" id="username" name="username" required>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="password">Password</label>
|
||
|
<input type="password" id="password" name="password" required>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="email">Email (optional)</label>
|
||
|
<input type="email" id="email" name="email">
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="displayName">Display Name (optional)</label>
|
||
|
<input type="text" id="displayName" name="displayName">
|
||
|
</div>
|
||
|
<div class="error-message" id="setupError" style="display: none;"></div>
|
||
|
<button type="submit" class="btn-primary">Create Admin Account</button>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
document.getElementById('setupForm').addEventListener('submit', async (e) => {
|
||
|
e.preventDefault();
|
||
|
const errorElement = document.getElementById('setupError');
|
||
|
errorElement.style.display = 'none';
|
||
|
|
||
|
const formData = {
|
||
|
username: document.getElementById('username').value,
|
||
|
password: document.getElementById('password').value,
|
||
|
email: document.getElementById('email').value || null,
|
||
|
display_name: document.getElementById('displayName').value || null
|
||
|
};
|
||
|
|
||
|
try {
|
||
|
const response = await fetch('/setup', {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
body: JSON.stringify(formData)
|
||
|
});
|
||
|
|
||
|
if (response.ok) {
|
||
|
window.location.href = '/login';
|
||
|
} else {
|
||
|
const data = await response.json().catch(() => null);
|
||
|
errorElement.textContent = data?.error || 'Failed to create admin account';
|
||
|
errorElement.style.display = 'block';
|
||
|
}
|
||
|
} catch (error) {
|
||
|
errorElement.textContent = 'An error occurred. Please try again.';
|
||
|
errorElement.style.display = 'block';
|
||
|
}
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|