-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.py
More file actions
55 lines (35 loc) · 1.85 KB
/
user.py
File metadata and controls
55 lines (35 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from datetime import datetime
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class UserCreate(BaseModel):
email: EmailStr = Field(description="User email address")
password: str = Field(min_length=8, max_length=100, description="Password")
class UserResponse(BaseModel):
id: str = Field(description="User ID")
email: str = Field(description="User email address")
role: str = Field(description="User role")
bio: str | None = Field(default=None, description="User bio")
created_at: datetime = Field(description="Creation timestamp")
is_active: bool = Field(description="Active status")
model_config = ConfigDict(from_attributes=True)
class UserProfileUpdate(BaseModel):
bio: str = Field(max_length=500, description="User bio")
class PasswordChangeRequest(BaseModel):
current_password: str = Field(min_length=1, description="Current password")
new_password: str = Field(min_length=8, max_length=100, description="New password")
class AdminUserResponse(BaseModel):
id: str = Field(description="User ID")
email: str = Field(description="User email address")
role: str = Field(description="User role")
bio: str | None = Field(default=None, description="User bio")
created_at: datetime = Field(description="Creation timestamp")
is_active: bool = Field(description="Active status")
model_config = ConfigDict(from_attributes=True)
class AdminPasswordReset(BaseModel):
new_password: str = Field(min_length=8, max_length=100, description="New password")
class AdminRoleChange(BaseModel):
role_id: str = Field(description="New role ID")
class RoleResponse(BaseModel):
id: str = Field(description="Role ID")
title: str = Field(description="Role title")
description: str | None = Field(default=None, description="Role description")
model_config = ConfigDict(from_attributes=True)