feat: Add password field to AuthUser schema and update user management logic
This commit introduces a new optional `password` field to the `AuthUserUpdateRequest` schema, allowing users to update their passwords. The ManageUsers component is updated to handle password input, including validation for minimum length and an option to keep the current password. Additionally, the backend logic is modified to hash and store the new password when provided. Documentation has been updated to reflect these changes.
This commit is contained in:
@@ -421,6 +421,12 @@ def update_auth_user(
|
||||
"has_write_access": request.has_write_access,
|
||||
}
|
||||
|
||||
# Update password if provided
|
||||
if request.password and request.password.strip():
|
||||
password_hash = hash_password(request.password)
|
||||
update_fields.append("password_hash = :password_hash")
|
||||
update_params["password_hash"] = password_hash
|
||||
|
||||
if request.is_active is not None:
|
||||
update_fields.append("is_active = :is_active")
|
||||
update_params["is_active"] = request.is_active
|
||||
|
||||
@@ -47,6 +47,7 @@ class AuthUserUpdateRequest(BaseModel):
|
||||
has_write_access: bool = Field(..., description="Write access (required)")
|
||||
is_active: Optional[bool] = Field(None, description="Active status (optional)")
|
||||
role: Optional[str] = Field(None, description="Role: 'Admin' or 'User' (optional)")
|
||||
password: Optional[str] = Field(None, min_length=6, description="New password (optional, minimum 6 characters, leave empty to keep current)")
|
||||
|
||||
|
||||
class AuthUsersListResponse(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user