Skip to content

Commit

Permalink
Merge branch 'dev' into feature/enable_guest_sessions_toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
IonesioJunior authored Aug 1, 2024
2 parents d85b4d4 + 91a4e61 commit 30290a5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/syft/src/syft/service/user/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,20 @@ def update(
# Get user to be updated by its UID
result = self.stash.get_by_uid(credentials=context.credentials, uid=uid)

immutable_fields = {"created_date", "updated_date", "deleted_date"}
updated_fields = user_update.to_dict(
exclude_none=True, exclude_empty=True
).keys()

for field_name in immutable_fields:
if field_name in updated_fields:
return SyftError(
message=f"You are not allowed to modify '{field_name}'."
)

if user_update.name is not Empty and user_update.name.strip() == "": # type: ignore[comparison-overlap]
return SyftError(message="Name can't be an empty string.")

# check if the email already exists (with root's key)
if user_update.email is not Empty:
user_with_email_exists: bool = self.stash.email_exists(
Expand Down

0 comments on commit 30290a5

Please sign in to comment.