42 lines
788 B
Python
42 lines
788 B
Python
import uuid
|
|
from datetime import datetime
|
|
from typing import Literal, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
username: str = Field(min_length=1)
|
|
role: Literal["PM", "CRA", "PV", "IMP"]
|
|
is_active: bool = True
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str = Field(min_length=1)
|
|
|
|
|
|
class UserRead(UserBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class UserInDB(UserBase):
|
|
id: uuid.UUID
|
|
hashed_password: str
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
|
|
|
|
class TokenPayload(BaseModel):
|
|
sub: uuid.UUID
|
|
role: str
|
|
exp: Optional[int] = None
|