-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_schema.py
More file actions
76 lines (48 loc) · 1.46 KB
/
auth_schema.py
File metadata and controls
76 lines (48 loc) · 1.46 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from pydantic import BaseModel, EmailStr, Field, field_validator, ConfigDict
from utils import validate_password
"""=== User ==="""
class UserResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
email: EmailStr
username: str | None = None
department: str | None = None
class UserUpdateSchema(BaseModel):
username: str | None = None
department_id: int | None = None
class UserTokenResponse(BaseModel):
access_token: str
refresh_token: str
token_type: str
user: UserResponse
"""=== Login ==="""
class LoginSchema(BaseModel):
email: EmailStr
password: str
"""=== Signup ==="""
class SignupSchema(BaseModel):
code: str
email: EmailStr
password: str
@field_validator("password")
@classmethod
def validate_password(cls, password: str) -> str:
return validate_password(password)
class SignupEmailConfirmSchema(BaseModel):
email: EmailStr
"""=== Tokens ==="""
class RefreshTokenSchema(BaseModel):
refresh_token: str
"""=== Reset Password ==="""
class RequestPasswordResetSchema(BaseModel):
email: EmailStr
class VerifyResetCodeSchema(BaseModel):
email: EmailStr
code: str
class ResetPasswordSchema(BaseModel):
reset_token: str
password: str = Field(min_length=8, max_length=72)
@field_validator("password")
@classmethod
def validate_password(cls, password: str) -> str:
return validate_password(password)