feat: implement initial admin setup (Story 1.1)
Add complete initial admin setup functionality including: - SetupForm with email, password, and password confirmation fields - Password validation (minimum 12 characters) and confirmation matching - Email format validation - Setup route with GET (display form) and POST (process setup) handlers - bcrypt password hashing before storing admin credentials - Auto-login after successful setup with session management - First-run detection middleware that redirects to /setup if no admin exists - Setup page returns 404 after admin account is created - Base HTML template with Pico CSS integration - Admin dashboard placeholder template - 404 error template All tests pass with 90.09% code coverage (exceeds 80% requirement). Code passes ruff linting and mypy type checking. Story: 1.1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
15
src/templates/admin/dashboard.html
Normal file
15
src/templates/admin/dashboard.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}Admin Dashboard - Sneaky Klaus{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
<header>
|
||||
<h1>Admin Dashboard</h1>
|
||||
</header>
|
||||
|
||||
<p>Welcome to the Sneaky Klaus admin dashboard!</p>
|
||||
|
||||
<p>This is a placeholder for the admin dashboard. More features coming soon.</p>
|
||||
</article>
|
||||
{% endblock %}
|
||||
12
src/templates/errors/404.html
Normal file
12
src/templates/errors/404.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}Page Not Found - Sneaky Klaus{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
<header>
|
||||
<h1>404 - Page Not Found</h1>
|
||||
</header>
|
||||
<p>The page you're looking for doesn't exist.</p>
|
||||
</article>
|
||||
{% endblock %}
|
||||
20
src/templates/layouts/base.html
Normal file
20
src/templates/layouts/base.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Sneaky Klaus{% endblock %}</title>
|
||||
|
||||
<!-- Pico CSS via CDN -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
|
||||
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
54
src/templates/setup.html
Normal file
54
src/templates/setup.html
Normal file
@@ -0,0 +1,54 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}Admin Setup - Sneaky Klaus{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<article style="max-width: 600px; margin: 4rem auto;">
|
||||
<header>
|
||||
<h1>Admin Setup</h1>
|
||||
<p>Create your administrator account to get started with Sneaky Klaus.</p>
|
||||
</header>
|
||||
|
||||
<form method="POST" action="{{ url_for('setup.setup') }}">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<div>
|
||||
<label for="email">
|
||||
{{ form.email.label.text }}
|
||||
{{ form.email(required=True) }}
|
||||
</label>
|
||||
{% if form.email.errors %}
|
||||
<small style="color: var(--pico-form-element-invalid-border-color);">
|
||||
{{ form.email.errors[0] }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password">
|
||||
{{ form.password.label.text }}
|
||||
{{ form.password(required=True) }}
|
||||
</label>
|
||||
{% if form.password.errors %}
|
||||
<small style="color: var(--pico-form-element-invalid-border-color);">
|
||||
{{ form.password.errors[0] }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password_confirm">
|
||||
{{ form.password_confirm.label.text }}
|
||||
{{ form.password_confirm(required=True) }}
|
||||
</label>
|
||||
{% if form.password_confirm.errors %}
|
||||
<small style="color: var(--pico-form-element-invalid-border-color);">
|
||||
{{ form.password_confirm.errors[0] }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<button type="submit">Create Admin Account</button>
|
||||
</form>
|
||||
</article>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user