cognee_http_server/dto/users.rs
1//! Shared user DTOs (UserReadDTO, UserUpdatePayloadDTO, InvalidPasswordDetailDTO).
2//! Used by auth_register, users, and users_by_email routers.
3
4use serde::{Deserialize, Serialize};
5use utoipa::ToSchema;
6use uuid::Uuid;
7
8/// Full user record returned by most user-management endpoints.
9/// Matches Python's `UserRead(BaseUser)` with cognee's `tenant_id` extension.
10/// Source: `cognee/modules/users/models/User.py:46-49`.
11#[derive(Debug, Clone, Serialize, ToSchema)]
12pub struct UserReadDTO {
13 pub id: Uuid,
14 pub email: String,
15 pub is_active: bool,
16 pub is_superuser: bool,
17 pub is_verified: bool,
18 pub tenant_id: Option<Uuid>,
19 pub parent_user_id: Option<Uuid>,
20}
21
22/// PATCH body for `/me` and `/{id}`. All fields optional.
23/// Pydantic source: `fastapi_users.schemas.BaseUserUpdate`.
24#[derive(Debug, Deserialize, ToSchema)]
25pub struct UserUpdatePayloadDTO {
26 /// New cleartext password. Validated before hashing.
27 pub password: Option<String>,
28 /// New email. Must be unique across users.
29 pub email: Option<String>,
30 /// `safe=True` on `/me` — silently stripped; allowed on `/{id}` for superusers.
31 #[serde(default)]
32 pub is_active: Option<bool>,
33 /// `safe=True` on `/me` — silently stripped.
34 #[serde(default)]
35 pub is_superuser: Option<bool>,
36 /// `safe=True` on `/me` — silently stripped.
37 #[serde(default)]
38 pub is_verified: Option<bool>,
39}