protected system - new users to be disabled by default
This commit is contained in:
parent
6060d74eb2
commit
f4b08a0bb6
1 changed files with 13 additions and 2 deletions
|
|
@ -493,7 +493,7 @@ class AppObjects:
|
|||
logger.error(f"Unexpected error creating user: {str(e)}")
|
||||
raise ValueError(f"Failed to create user: {str(e)}")
|
||||
|
||||
def updateUser(self, userId: str, updateData: Dict[str, Any]) -> User:
|
||||
def updateUser(self, userId: str, updateData: Union[Dict[str, Any], User]) -> User:
|
||||
"""Update a user's information"""
|
||||
try:
|
||||
# Get user
|
||||
|
|
@ -501,9 +501,20 @@ class AppObjects:
|
|||
if not user:
|
||||
raise ValueError(f"User {userId} not found")
|
||||
|
||||
# Convert updateData to dict if it's a User model
|
||||
if isinstance(updateData, User):
|
||||
updateDict = updateData.model_dump()
|
||||
else:
|
||||
updateDict = updateData.copy() if isinstance(updateData, dict) else updateData
|
||||
|
||||
# Remove id field from updateDict if present - we'll use userId from parameter
|
||||
updateDict.pop("id", None)
|
||||
|
||||
# Update user data using model
|
||||
updatedData = user.model_dump()
|
||||
updatedData.update(updateData)
|
||||
updatedData.update(updateDict)
|
||||
# Ensure ID matches userId parameter
|
||||
updatedData["id"] = userId
|
||||
updatedUser = User(**updatedData)
|
||||
|
||||
# Update user record
|
||||
|
|
|
|||
Loading…
Reference in a new issue