2025-03-26 17:10:58 +00:00

31 lines
1.0 KiB
Python

from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional
class AuthBase(BaseModel):
user_id: str = Field(..., description="User ID associated with the auth token")
token: str = Field(..., description="Authentication token")
is_blacklisted: bool = Field(default=False, description="Token blacklist status")
expires_at: datetime = Field(..., description="Token expiration timestamp")
class AuthCreate(AuthBase):
class Config:
schema_extra = {
"example": {
"user_id": "user123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_at": "2024-01-01T00:00:00Z"
}
}
class Auth(AuthBase):
class Config:
orm_mode = True
schema_extra = {
"example": {
"user_id": "user123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"is_blacklisted": False,
"expires_at": "2024-01-01T00:00:00Z"
}
}