A5: sign up, sign in, sign out, profile and the base layout (WEB-02, WEB-06, WEB-11, WEB-50..54)

Registration (case-insensitive unique names, 8-256 char passwords, no email),
sign-in with a generic error and a fresh session, internal-only ?next=,
POST-only sign-out, password change that closes the other sessions. The
failed-login backoff, the registration quota and the password-change guard
live in the database so every web process shares them; the client IP is the
last X-Forwarded-For hop. One responsive stylesheet with light/dark theme,
labelled fields, alerts and no inline scripts or styles; Italian error pages
and a readable CSRF failure. Mutation checks: open redirects, uncounted
failures and a missing CSRF middleware are all caught.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 14:07:45 +01:00
1 parent 1d4b53d778
commit efb3e2e702
28 files changed
+1232 -22

No files matched your search

+33
View File
@@ -1,6 +1,8 @@
from django.contrib.auth.decorators import login_required
from django.db import connection
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
from django.views.decorators.cache import never_cache
def home(request):
@@ -8,6 +10,13 @@ def home(request):
return render(request, "web/home.html")
@never_cache
@login_required
def app_home(request):
"""Placeholder of the player area (WEB-20): the play screen arrives with A7."""
return render(request, "web/app_home.html")
def health_live(request):
"""Liveness for the container healthcheck: the process answers and the database opens (ARC-73)."""
try:
@@ -16,3 +25,27 @@ def health_live(request):
except Exception:
return HttpResponse("database unavailable", status=503, content_type="text/plain")
return JsonResponse({"status": "ok"})
# Error pages in Italian, in the site's own layout, with a way out (WEB-06).
def csrf_failure(request, reason=""):
return render(request, "web/error.html", {
"title": "Sessione scaduta",
"message": "Il modulo non è più valido, probabilmente perché la pagina è rimasta aperta a lungo. "
"Ricarica la pagina e riprova.",
}, status=403)
def not_found(request, exception=None):
return render(request, "web/error.html", {
"title": "Pagina non trovata", "message": "L'indirizzo richiesto non esiste.",
}, status=404)
def server_error(request):
return render(request, "web/error.html", {
"title": "Qualcosa è andato storto",
"message": "Si è verificato un errore. Riprova fra qualche istante.",
}, status=500)