"feat: Introduce backup and temp app modules, refactor database"

This commit is contained in:
Till Tomczak 2025-05-29 11:43:29 +02:00
parent fb0e00f2a0
commit fef6c0e723
5 changed files with 8268 additions and 21 deletions

View File

@ -51,22 +51,6 @@ app.config["WTF_CSRF_ENABLED"] = True
csrf = CSRFProtect(app)
# CSRF-Error-Handler
@csrf.error_handler
def csrf_error(reason):
"""Behandelt CSRF-Fehler und gibt detaillierte Informationen zurück."""
app_logger.error(f"CSRF-Fehler für {request.path}: {reason}")
if request.path.startswith('/api/'):
# Für API-Anfragen: JSON-Response
return jsonify({
"error": "CSRF-Token fehlt oder ungültig",
"reason": str(reason),
"help": "Fügen Sie ein gültiges CSRF-Token zu Ihrer Anfrage hinzu"
}), 400
else:
# Für normale Anfragen: Weiterleitung zur Fehlerseite
flash("Sicherheitsfehler: Anfrage wurde abgelehnt. Bitte versuchen Sie es erneut.", "error")
return redirect(request.url)
# Blueprints registrieren
app.register_blueprint(guest_blueprint)
@ -519,7 +503,6 @@ def api_callback():
"redirect_url": url_for("login")
}), 500
def handle_github_callback(code):
"""GitHub OAuth-Callback verarbeiten"""
try:
@ -565,7 +548,6 @@ def handle_github_callback(code):
auth_logger.error(f"Fehler bei GitHub OAuth-Callback: {str(e)}")
return None
def get_github_user_data(access_token):
"""GitHub-Benutzerdaten mit Access Token abrufen"""
try:
@ -2570,8 +2552,6 @@ def internal_error(error):
def forbidden_error(error):
return render_template('errors/403.html'), 403
# ===== ADMIN - DATENBANK-VERWALTUNG =====
@app.route('/api/admin/database/stats', methods=['GET'])
@ -4070,7 +4050,6 @@ def mark_all_notifications_read():
# ===== ENDE BENACHRICHTIGUNGS-API-ENDPUNKTE =====
# ===== STARTUP UND MAIN =====
if __name__ == "__main__":
import sys

4130
backend/app/app_backup.py Normal file

File diff suppressed because it is too large Load Diff

4116
backend/app/app_temp.py Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

22
backend/app/fix_csrf.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""Entferne problematischen CSRF-Error-Handler aus app.py"""
import re
# Lese die Backup-Datei
with open('app_backup.py', 'r', encoding='utf-8') as f:
content = f.read()
# Entferne den CSRF-Error-Handler-Block
# Suche nach @csrf.error_handler bis zum ersten leeren Zeilen-Block
pattern = r'@csrf\.error_handler.*?(?=\n\n|\n# [A-Z])'
content = re.sub(pattern, '', content, flags=re.DOTALL)
# Entferne auch mögliche doppelte Leerzeilen
content = re.sub(r'\n\n\n+', '\n\n', content)
# Schreibe die bereinigte Version
with open('app.py', 'w', encoding='utf-8') as f:
f.write(content)
print("CSRF-Error-Handler erfolgreich entfernt!")