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:
+7
-2
@@ -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')
|
||||
Reference in New Issue
Block a user