This commit is contained in:
@@ -14,6 +14,17 @@ class LoginRequest(BaseModel):
|
||||
password: str
|
||||
|
||||
|
||||
class ChangePasswordRequest(BaseModel):
|
||||
current_password: str = Field(min_length=1, max_length=256)
|
||||
new_password: str = Field(min_length=12, max_length=256)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def reject_same_password(self):
|
||||
if self.current_password == self.new_password:
|
||||
raise ValueError("新密码不能与当前密码相同")
|
||||
return self
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
id: UUID
|
||||
|
||||
Reference in New Issue
Block a user