Add comprehensive backend features and mobile UI improvements
Backend: - Add 2FA authentication with TOTP support - Add API keys management system - Add audit logging for security events - Add file upload/management system - Add notifications system with preferences - Add session management - Add webhooks integration - Add analytics endpoints - Add export functionality - Add password policy enforcement - Add new database migrations for core tables Frontend: - Add module position system (top/bottom sidebar sections) - Add search and notifications module configuration tabs - Add mobile logo replacing hamburger menu - Center page title absolutely when no tabs present - Align sidebar footer toggles with navigation items - Add lighter icon color in dark theme for mobile - Add API keys management page - Add notifications page with context - Add admin analytics and audit logs pages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
46
backend/app/models/session.py
Normal file
46
backend/app/models/session.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""User session database model for tracking active sessions."""
|
||||
|
||||
import uuid
|
||||
from sqlalchemy import Column, String, Boolean, ForeignKey, Text
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.types import DateTime
|
||||
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class UserSession(Base):
|
||||
"""User session model for tracking active sessions."""
|
||||
|
||||
__tablename__ = "user_sessions"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
|
||||
# User
|
||||
user_id = Column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
|
||||
# Token hash (to identify and revoke specific sessions)
|
||||
token_hash = Column(String(64), unique=True, nullable=False, index=True)
|
||||
|
||||
# Device/client info
|
||||
device_name = Column(String(200), nullable=True) # User-friendly name
|
||||
device_type = Column(String(50), nullable=True) # desktop, mobile, tablet
|
||||
browser = Column(String(100), nullable=True)
|
||||
os = Column(String(100), nullable=True)
|
||||
user_agent = Column(String(500), nullable=True)
|
||||
|
||||
# Location info
|
||||
ip_address = Column(String(45), nullable=True)
|
||||
location = Column(String(200), nullable=True) # City, Country
|
||||
|
||||
# Status
|
||||
is_active = Column(Boolean, default=True, nullable=False)
|
||||
is_current = Column(Boolean, default=False, nullable=False) # Marks the current session
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, server_default=func.now(), nullable=False, index=True)
|
||||
last_active_at = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
expires_at = Column(DateTime, nullable=True)
|
||||
revoked_at = Column(DateTime, nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<UserSession(id={self.id}, user_id={self.user_id}, device={self.device_name})>"
|
||||
Reference in New Issue
Block a user