82 Zeilen
3.2 KiB
Python
82 Zeilen
3.2 KiB
Python
"""
|
|
One-Click Login Use Case - Ermöglicht Login mit gespeicherter Session
|
|
"""
|
|
|
|
import logging
|
|
from typing import Dict, Any, Optional, Tuple
|
|
from datetime import datetime
|
|
|
|
from domain.value_objects.login_credentials import LoginCredentials
|
|
from infrastructure.repositories.fingerprint_repository import FingerprintRepository
|
|
from infrastructure.repositories.account_repository import AccountRepository
|
|
|
|
logger = logging.getLogger("one_click_login_use_case")
|
|
|
|
|
|
class OneClickLoginUseCase:
|
|
"""
|
|
Use Case für Ein-Klick-Login mit gespeicherter Session.
|
|
Lädt Session und Fingerprint für konsistenten Browser-Start.
|
|
"""
|
|
|
|
def __init__(self,
|
|
fingerprint_repository: FingerprintRepository = None,
|
|
account_repository: AccountRepository = None):
|
|
self.fingerprint_repository = fingerprint_repository
|
|
self.account_repository = account_repository
|
|
|
|
def execute(self, account_id: str, platform: str) -> Dict[str, Any]:
|
|
"""
|
|
Ein-Klick-Login deaktiviert - führt immer normalen Login durch.
|
|
|
|
Args:
|
|
account_id: ID des Accounts
|
|
platform: Plattform (instagram, facebook, etc.)
|
|
|
|
Returns:
|
|
Dict mit Anweisung für normalen Login
|
|
"""
|
|
try:
|
|
# Session-Login deaktiviert - führe immer normalen Login durch
|
|
logger.info(f"Session-Login deaktiviert für Account {account_id} - verwende normalen Login")
|
|
|
|
# Account-Daten laden falls Repository verfügbar
|
|
account_data = None
|
|
if self.account_repository:
|
|
try:
|
|
account = self.account_repository.get_by_id(int(account_id))
|
|
if account:
|
|
account_data = {
|
|
'username': account.get('username'),
|
|
'password': account.get('password'),
|
|
'platform': account.get('platform'),
|
|
'fingerprint_id': account.get('fingerprint_id')
|
|
}
|
|
except Exception as e:
|
|
logger.error(f"Fehler beim Laden der Account-Daten: {e}")
|
|
|
|
return {
|
|
'success': False, # Kein Session-Login möglich
|
|
'can_perform_login': True, # Normaler Login möglich
|
|
'account_data': account_data,
|
|
'message': 'Session-Login deaktiviert - normaler Login erforderlich',
|
|
'requires_manual_login': False
|
|
}
|
|
|
|
except Exception as e:
|
|
logger.error(f"Fehler beim One-Click-Login: {e}")
|
|
return {
|
|
'success': False,
|
|
'can_perform_login': True,
|
|
'account_data': None,
|
|
'message': f'Fehler beim Login: {str(e)}',
|
|
'requires_manual_login': False
|
|
}
|
|
|
|
def check_session_status(self, account_id: str) -> Dict[str, Any]:
|
|
"""
|
|
Session-Status-Check deaktiviert (Session-Funktionalität entfernt).
|
|
"""
|
|
# Session-Funktionalität wurde entfernt
|
|
return {'state': 'unknown', 'message': 'Session-Status deaktiviert'}
|