Fix: Admin-Routen vollständig stabilisieren

- admin_routes.py: Robuste Fehlerbehandlung für fehlende 'config' Tabelle
- admin_routes.py: Alle Endpunkte mit try/except geschützt
- login_routes.py: /admin Route hinzugefügt (fehlte nach Refactoring)
- SMTP/LLM/Hours APIs funktionieren jetzt auch ohne bestehende Config

Closes: 500er Fehler bei SMTP und LLM Konfiguration
This commit is contained in:
Peter (OpenClaw)
2026-05-27 08:23:43 +00:00
parent daaa9bff5e
commit a5e2788d57
2 changed files with 210 additions and 394 deletions
+7 -2
View File
@@ -1,5 +1,5 @@
"""Login und Captcha Routes"""
from flask import Blueprint, request, jsonify, session
from flask import Blueprint, request, jsonify, session, render_template, redirect
from auth import generate_captcha, verify_captcha, check_admin_password
auth_bp = Blueprint('auth', __name__)
@@ -7,7 +7,6 @@ auth_bp = Blueprint('auth', __name__)
@auth_bp.route('/api/captcha', methods=['GET'])
def get_captcha():
captcha = generate_captcha()
# captcha enthaelt jetzt 'image' und 'token' (kein 'answer' mehr)
return jsonify({"image": captcha["image"], "token": captcha["token"]})
@auth_bp.route('/api/admin/login', methods=['POST'])
@@ -33,3 +32,9 @@ def check_session():
if role:
return jsonify({"role": role, "logged_in": True})
return jsonify({"logged_in": False})
@auth_bp.route('/admin')
def admin_dashboard():
if session.get('user_role') != 'admin':
return redirect('/')
return render_template('admin.html')