36 lines
1002 B
Python
36 lines
1002 B
Python
from pydantic import BaseModel, Field, EmailStr
|
|
from typing import Optional, Literal
|
|
from datetime import datetime
|
|
|
|
class UserBase(BaseModel):
|
|
username: str = Field(..., min_length=3, max_length=50)
|
|
email: Optional[EmailStr] = None
|
|
type: Literal["agent", "person", "company", "state"] = "person"
|
|
is_judge: bool = False
|
|
|
|
class UserCreate(UserBase):
|
|
password: Optional[str] = Field(None, min_length=8)
|
|
public_key: Optional[str] = None
|
|
|
|
class AgentRegister(BaseModel):
|
|
username: str = Field(..., min_length=3, max_length=50)
|
|
public_key: str = Field(..., min_length=10)
|
|
email: Optional[EmailStr] = None
|
|
type: Literal["agent", "company", "state"] = "agent"
|
|
|
|
class UserResponse(UserBase):
|
|
id: int
|
|
reputation_score: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
|
|
class TokenData(BaseModel):
|
|
username: Optional[str] = None
|