Security Features:
- Added User model with bcrypt password hashing
- Implemented Flask-Login for session management
- Protected all API write operations with @login_required decorator
- Added authentication routes (login/logout)
Admin Dashboard:
- Created comprehensive admin dashboard with statistics
- Profile management interface
- Skills management (add/edit/delete)
- Projects management with full CRUD operations
- Social links management
- Modern responsive UI with Bootstrap 5
New Files:
- models.py: Added User model with bcrypt
- routes/auth.py: Login/logout functionality
- routes/admin.py: Complete admin dashboard with CRUD operations
- templates/auth/login.html: Login page
- templates/admin/base.html: Admin base template
- templates/admin/dashboard.html: Main dashboard
- templates/admin/profile.html: Profile editor
- templates/admin/skills.html: Skills manager
- templates/admin/projects.html: Projects list
- templates/admin/project_form.html: Project editor
- templates/admin/social_links.html: Social links manager
Modified Files:
- app.py: Integrated Flask-Login and bcrypt, registered new blueprints
- requirements.txt: Added Flask-Login, Flask-Bcrypt, bcrypt
- init_db.py: Creates default admin user (admin/admin123)
- routes/api.py: Protected all write operations with authentication
Default Credentials:
- Username: admin
- Password: admin123
- ⚠️ MUST be changed after first login!
Benefits:
- Secure API access with session-based authentication
- User-friendly admin interface for content management
- No need to edit code or database directly
- Bcrypt password hashing for security
- Protected against unauthorized access
55 lines
2.4 KiB
HTML
55 lines
2.4 KiB
HTML
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}Gestione Profilo{% endblock %}
|
|
{% block page_title %}Gestione Profilo{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form method="POST" action="{{ url_for('admin.profile_edit') }}">
|
|
<div class="mb-3">
|
|
<label for="title" class="form-label">Titolo</label>
|
|
<input type="text" class="form-control" id="title" name="title"
|
|
value="{{ profile.title if profile else '' }}" required>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="lead_text" class="form-label">Testo Principale</label>
|
|
<textarea class="form-control" id="lead_text" name="lead_text" rows="3" required>{{ profile.lead_text if profile else '' }}</textarea>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="description_1" class="form-label">Descrizione 1</label>
|
|
<textarea class="form-control" id="description_1" name="description_1" rows="3">{{ profile.description_1 if profile else '' }}</textarea>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="description_2" class="form-label">Descrizione 2</label>
|
|
<textarea class="form-control" id="description_2" name="description_2" rows="3">{{ profile.description_2 if profile else '' }}</textarea>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="years_experience" class="form-label">Anni di Esperienza</label>
|
|
<input type="number" class="form-control" id="years_experience" name="years_experience"
|
|
value="{{ profile.years_experience if profile else 0 }}">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="cv_url" class="form-label">URL CV (opzionale)</label>
|
|
<input type="url" class="form-control" id="cv_url" name="cv_url"
|
|
value="{{ profile.cv_url if profile else '' }}">
|
|
</div>
|
|
|
|
<div class="d-flex gap-2">
|
|
<button type="submit" class="btn btn-gradient">
|
|
<i class="fas fa-save me-2"></i>Salva Modifiche
|
|
</button>
|
|
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-times me-2"></i>Annulla
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|