"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 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.
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