bbbf97d027
- Revert auth/dependencies.py to cookie+Bearer dual auth with str user IDs - Add GET /auth/me/email-in-address endpoint for receipt email routing - Update User model: add email_inbound_token, change id/store_id/user_id to str - Update AuthService and UserResponse to use str user IDs - Update route count test: 33 -> 34 routes - Restore e2e test for email-in-address endpoint Co-Authored-By: Paperclip <noreply@paperclip.ing>
31 lines
862 B
Python
31 lines
862 B
Python
"""Base model and mixins for all CartSnitch ORM models."""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, func
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
"""Base class for all CartSnitch models."""
|
|
|
|
|
|
class TimestampMixin:
|
|
"""Mixin providing created_at / updated_at columns."""
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now(), nullable=False
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False
|
|
)
|
|
|
|
|
|
class UUIDPrimaryKeyMixin:
|
|
"""Mixin providing a UUID primary key."""
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
primary_key=True, default=uuid.uuid4, server_default=func.gen_random_uuid()
|
|
)
|