"Refactor database configuration for improved performance (feat)"
This commit is contained in:
parent
9462ac874d
commit
3e514f3733
@ -22,6 +22,7 @@ from sqlalchemy.orm import joinedload
|
|||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from PyP100 import PyP110
|
from PyP100 import PyP110
|
||||||
from flask_wtf.csrf import CSRFProtect
|
from flask_wtf.csrf import CSRFProtect
|
||||||
|
from flask_wtf.csrf import CSRFError
|
||||||
|
|
||||||
from config.settings import (
|
from config.settings import (
|
||||||
SECRET_KEY, TAPO_USERNAME, TAPO_PASSWORD, PRINTERS,
|
SECRET_KEY, TAPO_USERNAME, TAPO_PASSWORD, PRINTERS,
|
||||||
@ -50,17 +51,17 @@ app.config["WTF_CSRF_ENABLED"] = True
|
|||||||
# CSRF-Schutz initialisieren
|
# CSRF-Schutz initialisieren
|
||||||
csrf = CSRFProtect(app)
|
csrf = CSRFProtect(app)
|
||||||
|
|
||||||
# CSRF-Error-Handler
|
# CSRF-Error-Handler - Korrigierte Version für Flask-WTF 1.2.1+
|
||||||
@csrf.error_handler
|
@app.errorhandler(CSRFError)
|
||||||
def csrf_error(reason):
|
def csrf_error(error):
|
||||||
"""Behandelt CSRF-Fehler und gibt detaillierte Informationen zurück."""
|
"""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/'):
|
if request.path.startswith('/api/'):
|
||||||
# Für API-Anfragen: JSON-Response
|
# Für API-Anfragen: JSON-Response
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"error": "CSRF-Token fehlt oder ungültig",
|
"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"
|
"help": "Fügen Sie ein gültiges CSRF-Token zu Ihrer Anfrage hinzu"
|
||||||
}), 400
|
}), 400
|
||||||
else:
|
else:
|
||||||
|
Binary file not shown.
Binary file not shown.
2
backend/app/static/css/tailwind.min.css
vendored
2
backend/app/static/css/tailwind.min.css
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user