Improve the frontend modals

This commit is contained in:
Urtzi Alfaro
2025-10-27 16:33:26 +01:00
parent 61376b7a9f
commit 858d985c92
143 changed files with 9289 additions and 2306 deletions

View File

@@ -86,12 +86,12 @@ class DataExportService:
active_sessions = []
for token in tokens:
if token.expires_at > datetime.now(timezone.utc) and not token.revoked:
if token.expires_at > datetime.now(timezone.utc) and not token.is_revoked:
active_sessions.append({
"token_id": str(token.id),
"created_at": token.created_at.isoformat() if token.created_at else None,
"expires_at": token.expires_at.isoformat() if token.expires_at else None,
"device_info": token.device_info
"is_revoked": token.is_revoked
})
return {
@@ -118,9 +118,22 @@ class DataExportService:
async def _export_security_data(self, user_id: UUID) -> Dict[str, Any]:
"""Export security-related data"""
# First get user email
user_query = select(User).where(User.id == user_id)
user_result = await self.db.execute(user_query)
user = user_result.scalar_one_or_none()
if not user:
return {
"recent_login_attempts": [],
"total_attempts_exported": 0,
"note": "User not found"
}
# LoginAttempt uses email, not user_id
query = select(LoginAttempt).where(
LoginAttempt.user_id == user_id
).order_by(LoginAttempt.attempted_at.desc()).limit(50)
LoginAttempt.email == user.email
).order_by(LoginAttempt.created_at.desc()).limit(50)
result = await self.db.execute(query)
attempts = result.scalars().all()
@@ -128,7 +141,7 @@ class DataExportService:
login_attempts = []
for attempt in attempts:
login_attempts.append({
"attempted_at": attempt.attempted_at.isoformat() if attempt.attempted_at else None,
"attempted_at": attempt.created_at.isoformat() if attempt.created_at else None,
"success": attempt.success,
"ip_address": attempt.ip_address,
"user_agent": attempt.user_agent,