59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: EmailStr
|
|
username: str = Field(min_length=3, max_length=100)
|
|
full_name: str = Field(min_length=1, max_length=255)
|
|
employee_id: str | None = Field(default=None, max_length=100)
|
|
phone: str | None = Field(default=None, max_length=50)
|
|
occupation: str | None = Field(default=None, max_length=150)
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str = Field(min_length=8, max_length=128)
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
full_name: str | None = Field(default=None, min_length=1, max_length=255)
|
|
employee_id: str | None = Field(default=None, max_length=100)
|
|
phone: str | None = Field(default=None, max_length=50)
|
|
occupation: str | None = Field(default=None, max_length=150)
|
|
|
|
|
|
class UserResponse(UserBase):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class LoginRequest(BaseModel):
|
|
username_or_email: str = Field(min_length=1)
|
|
password: str = Field(min_length=1)
|
|
remember_me: bool = False
|
|
|
|
|
|
class TokenResponse(BaseModel):
|
|
access_token: str
|
|
refresh_token: str
|
|
token_type: str = "bearer"
|
|
user: UserResponse
|
|
|
|
|
|
class ForgotPasswordRequest(BaseModel):
|
|
email: EmailStr
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
token: str
|
|
new_password: str = Field(min_length=8, max_length=128)
|
|
|
|
|
|
class MessageResponse(BaseModel):
|
|
message: str
|
|
reset_token: str | None = None
|