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:
tanyar09
2025-12-05 15:08:26 -05:00
parent 8f31e1942f
commit 0a109b198a
4 changed files with 32 additions and 0 deletions
+6
View File
@@ -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
+1
View File
@@ -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):