"Refactor database configuration for improved performance (feat)"

This commit is contained in:
Till Tomczak 2025-05-29 11:59:23 +02:00
parent 9462ac874d
commit 3e514f3733
4 changed files with 7 additions and 6 deletions

View File

@ -22,6 +22,7 @@ from sqlalchemy.orm import joinedload
from sqlalchemy import func
from PyP100 import PyP110
from flask_wtf.csrf import CSRFProtect
from flask_wtf.csrf import CSRFError
from config.settings import (
SECRET_KEY, TAPO_USERNAME, TAPO_PASSWORD, PRINTERS,
@ -50,17 +51,17 @@ app.config["WTF_CSRF_ENABLED"] = True
# CSRF-Schutz initialisieren
csrf = CSRFProtect(app)
# CSRF-Error-Handler
@csrf.error_handler
def csrf_error(reason):
# CSRF-Error-Handler - Korrigierte Version für Flask-WTF 1.2.1+
@app.errorhandler(CSRFError)
def csrf_error(error):
"""Behandelt CSRF-Fehler und gibt detaillierte Informationen zurück."""
app_logger.error(f"CSRF-Fehler für {request.path}: {reason}")
app_logger.error(f"CSRF-Fehler für {request.path}: {error}")
if request.path.startswith('/api/'):
# Für API-Anfragen: JSON-Response
return jsonify({
"error": "CSRF-Token fehlt oder ungültig",
"reason": str(reason),
"reason": str(error),
"help": "Fügen Sie ein gültiges CSRF-Token zu Ihrer Anfrage hinzu"
}), 400
else:

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long