mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-30 04:31:49 +02:00
* functional initial auth modal * k * k * k * looking good * k * k * k * k * update * k * k * misc bunch * improvements * k * address comments * k * nit * update * k
58 lines
1.1 KiB
Python
58 lines
1.1 KiB
Python
from typing import Generic
|
|
from typing import Optional
|
|
from typing import TypeVar
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from onyx.auth.schemas import UserRole
|
|
from onyx.db.models import User
|
|
|
|
|
|
DataT = TypeVar("DataT")
|
|
|
|
|
|
class StatusResponse(BaseModel, Generic[DataT]):
|
|
success: bool
|
|
message: Optional[str] = None
|
|
data: Optional[DataT] = None
|
|
|
|
|
|
class ApiKey(BaseModel):
|
|
api_key: str
|
|
|
|
|
|
class IdReturn(BaseModel):
|
|
id: int
|
|
|
|
|
|
class MinimalUserSnapshot(BaseModel):
|
|
id: UUID
|
|
email: str
|
|
|
|
|
|
class FullUserSnapshot(BaseModel):
|
|
id: UUID
|
|
email: str
|
|
role: UserRole
|
|
is_active: bool
|
|
password_configured: bool
|
|
|
|
@classmethod
|
|
def from_user_model(cls, user: User) -> "FullUserSnapshot":
|
|
return cls(
|
|
id=user.id,
|
|
email=user.email,
|
|
role=user.role,
|
|
is_active=user.is_active,
|
|
password_configured=user.password_configured,
|
|
)
|
|
|
|
|
|
class DisplayPriorityRequest(BaseModel):
|
|
display_priority_map: dict[int, int]
|
|
|
|
|
|
class InvitedUserSnapshot(BaseModel):
|
|
email: str
|