Die Dateien, die hinzugefügt wurden, sind Teil des Backend-Projekts und befinden sich in verschiedenen Log- und Konfigurationsverzeichnissen. Hier ist eine Aufschlüsselung der hinzugefügten Dateien:
This commit is contained in:
@ -402,7 +402,7 @@ from blueprints.kiosk import kiosk_blueprint
|
||||
from blueprints.uploads import uploads_blueprint
|
||||
from blueprints.sessions import sessions_blueprint
|
||||
from blueprints.tapo_control import tapo_blueprint # Tapo-Steckdosen-Steuerung
|
||||
from blueprints.api_simple import api_blueprint # Einfache API-Endpunkte
|
||||
from blueprints.api import api_blueprint # API-Endpunkte mit Session-Management
|
||||
|
||||
# Import der Sicherheits- und Hilfssysteme
|
||||
from utils.security_suite import init_security
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/blueprints/__pycache__/api.cpython-313.pyc
Normal file
BIN
backend/blueprints/__pycache__/api.cpython-313.pyc
Normal file
Binary file not shown.
@ -136,4 +136,132 @@ def heartbeat():
|
||||
})
|
||||
except Exception as e:
|
||||
api_logger.error(f"Fehler im Heartbeat: {str(e)}")
|
||||
return jsonify({'error': 'Heartbeat-Fehler'}), 500
|
||||
return jsonify({'error': 'Heartbeat-Fehler'}), 500
|
||||
|
||||
@api_blueprint.route('/session/status', methods=['GET'])
|
||||
def session_status():
|
||||
"""Gibt den aktuellen Session-Status zurück"""
|
||||
try:
|
||||
if current_user.is_authenticated:
|
||||
# Benutzer ist angemeldet
|
||||
from datetime import timedelta
|
||||
from backend.config.settings import SESSION_LIFETIME
|
||||
|
||||
# Session-Informationen sammeln
|
||||
session_start = session.get('session_start')
|
||||
last_activity = session.get('last_activity', datetime.now().isoformat())
|
||||
|
||||
# Standard Session-Lifetime verwenden
|
||||
max_inactive_minutes = int(SESSION_LIFETIME.total_seconds() / 60)
|
||||
|
||||
# Verbleibende Zeit berechnen
|
||||
if isinstance(last_activity, str):
|
||||
try:
|
||||
last_activity_dt = datetime.fromisoformat(last_activity.replace('Z', '+00:00'))
|
||||
except:
|
||||
last_activity_dt = datetime.now()
|
||||
else:
|
||||
last_activity_dt = datetime.now()
|
||||
|
||||
time_since_activity = datetime.now() - last_activity_dt
|
||||
time_left_seconds = max(0, (SESSION_LIFETIME.total_seconds() - time_since_activity.total_seconds()))
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'user': {
|
||||
'id': current_user.id,
|
||||
'username': current_user.username,
|
||||
'email': current_user.email,
|
||||
'is_admin': current_user.is_admin
|
||||
},
|
||||
'session': {
|
||||
'is_authenticated': True,
|
||||
'max_inactive_minutes': max_inactive_minutes,
|
||||
'time_left_seconds': int(time_left_seconds),
|
||||
'last_activity': last_activity,
|
||||
'session_start': session_start
|
||||
},
|
||||
'timestamp': datetime.now().isoformat()
|
||||
})
|
||||
else:
|
||||
# Benutzer ist nicht angemeldet
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'user': None,
|
||||
'session': {
|
||||
'is_authenticated': False,
|
||||
'max_inactive_minutes': 0,
|
||||
'time_left_seconds': 0,
|
||||
'last_activity': None,
|
||||
'session_start': None
|
||||
},
|
||||
'timestamp': datetime.now().isoformat()
|
||||
})
|
||||
except Exception as e:
|
||||
api_logger.error(f"Fehler beim Abrufen des Session-Status: {str(e)}")
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': 'Session-Status nicht verfügbar',
|
||||
'message': str(e)
|
||||
}), 500
|
||||
|
||||
@api_blueprint.route('/session/heartbeat', methods=['POST'])
|
||||
@login_required
|
||||
def session_heartbeat():
|
||||
"""Session-Heartbeat für automatische Verlängerung"""
|
||||
try:
|
||||
# Letzte Aktivität NICHT in Cookie speichern (Cookie-Größe reduzieren)
|
||||
# session['last_activity'] = datetime.now().isoformat() # ENTFERNT
|
||||
|
||||
# Session als permanent markieren für Verlängerung
|
||||
session.permanent = True
|
||||
|
||||
# Verbleibende Session-Zeit berechnen
|
||||
from backend.config.settings import SESSION_LIFETIME
|
||||
time_left_seconds = int(SESSION_LIFETIME.total_seconds())
|
||||
|
||||
api_logger.debug(f"Session-Heartbeat von Benutzer {current_user.username}")
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': 'Session aktualisiert',
|
||||
'time_left_seconds': time_left_seconds,
|
||||
'timestamp': datetime.now().isoformat()
|
||||
})
|
||||
except Exception as e:
|
||||
api_logger.error(f"Fehler beim Session-Heartbeat: {str(e)}")
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': 'Session-Heartbeat fehlgeschlagen',
|
||||
'message': str(e)
|
||||
}), 500
|
||||
|
||||
@api_blueprint.route('/session/extend', methods=['POST'])
|
||||
@login_required
|
||||
def extend_session():
|
||||
"""Verlängert die aktuelle Session"""
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
extend_minutes = data.get('extend_minutes', 30)
|
||||
|
||||
# Session verlängern durch Markierung als permanent
|
||||
session.permanent = True
|
||||
|
||||
# Neue Aktivitätszeit NICHT in Cookie speichern
|
||||
# session['last_activity'] = datetime.now().isoformat() # ENTFERNT
|
||||
|
||||
api_logger.info(f"Session für Benutzer {current_user.username} um {extend_minutes} Minuten verlängert")
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': f'Session um {extend_minutes} Minuten verlängert',
|
||||
'extended_minutes': extend_minutes,
|
||||
'timestamp': datetime.now().isoformat()
|
||||
})
|
||||
except Exception as e:
|
||||
api_logger.error(f"Fehler beim Verlängern der Session: {str(e)}")
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': 'Session-Verlängerung fehlgeschlagen',
|
||||
'message': str(e)
|
||||
}), 500
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user