- Rewrite auth.py for multi-user schema (users table with roles) - Auto-migrate from single-user admin_user table to new schema - Add @admin_required decorator for protected routes - Admin routes: /admin/users, /admin/users/new, delete, reset-password - New templates: admin/users.html, user_new.html, user_created.html, password_reset.html - Update login.html for username field, base.html and account.html for admin nav - Max 16 users + 1 admin, session invalidation on delete/password reset 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
116 lines
4.7 KiB
HTML
116 lines
4.7 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Account - Stegasoo{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6 col-lg-5">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0"><i class="bi bi-person-gear me-2"></i>Account Settings</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted mb-4">
|
|
Logged in as <strong>{{ username }}</strong>
|
|
{% if is_admin %}
|
|
<span class="badge bg-warning text-dark ms-2">
|
|
<i class="bi bi-shield-check me-1"></i>Admin
|
|
</span>
|
|
{% endif %}
|
|
</p>
|
|
|
|
{% if is_admin %}
|
|
<div class="mb-4">
|
|
<a href="{{ url_for('admin_users') }}" class="btn btn-outline-primary w-100">
|
|
<i class="bi bi-people me-2"></i>Manage Users
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<h6 class="text-muted mb-3">Change Password</h6>
|
|
|
|
<form method="POST" action="{{ url_for('account') }}" id="accountForm">
|
|
<div class="mb-3">
|
|
<label class="form-label">
|
|
<i class="bi bi-key me-1"></i> Current Password
|
|
</label>
|
|
<div class="input-group">
|
|
<input type="password" name="current_password" class="form-control"
|
|
id="currentPasswordInput" required>
|
|
<button class="btn btn-outline-secondary" type="button"
|
|
onclick="togglePassword('currentPasswordInput', this)">
|
|
<i class="bi bi-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">
|
|
<i class="bi bi-key-fill me-1"></i> New Password
|
|
</label>
|
|
<div class="input-group">
|
|
<input type="password" name="new_password" class="form-control"
|
|
id="newPasswordInput" required minlength="8">
|
|
<button class="btn btn-outline-secondary" type="button"
|
|
onclick="togglePassword('newPasswordInput', this)">
|
|
<i class="bi bi-eye"></i>
|
|
</button>
|
|
</div>
|
|
<div class="form-text">Minimum 8 characters</div>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label class="form-label">
|
|
<i class="bi bi-key-fill me-1"></i> Confirm New Password
|
|
</label>
|
|
<div class="input-group">
|
|
<input type="password" name="new_password_confirm" class="form-control"
|
|
id="newPasswordConfirmInput" required minlength="8">
|
|
<button class="btn btn-outline-secondary" type="button"
|
|
onclick="togglePassword('newPasswordConfirmInput', this)">
|
|
<i class="bi bi-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-100">
|
|
<i class="bi bi-check-lg me-2"></i>Update Password
|
|
</button>
|
|
</form>
|
|
|
|
<hr class="my-4">
|
|
|
|
<a href="{{ url_for('logout') }}" class="btn btn-outline-danger w-100">
|
|
<i class="bi bi-box-arrow-left me-2"></i>Logout
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
function togglePassword(inputId, btn) {
|
|
const input = document.getElementById(inputId);
|
|
const icon = btn.querySelector('i');
|
|
if (input.type === 'password') {
|
|
input.type = 'text';
|
|
icon.classList.replace('bi-eye', 'bi-eye-slash');
|
|
} else {
|
|
input.type = 'password';
|
|
icon.classList.replace('bi-eye-slash', 'bi-eye');
|
|
}
|
|
}
|
|
|
|
document.getElementById('accountForm')?.addEventListener('submit', function(e) {
|
|
const newPass = document.getElementById('newPasswordInput').value;
|
|
const confirm = document.getElementById('newPasswordConfirmInput').value;
|
|
if (newPass !== confirm) {
|
|
e.preventDefault();
|
|
alert('New passwords do not match');
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|