core: fix UserSelfSerializer's save() overwriting other user attributes

closes #2070

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-01-06 18:23:06 +01:00
parent 22d6621b02
commit 03503363e5
2 changed files with 14 additions and 0 deletions

View File

@ -156,6 +156,13 @@ class UserSelfSerializer(ModelSerializer):
raise ValidationError("Not allowed to change username.")
return username
def save(self, **kwargs):
if self.instance:
attributes: dict = self.instance.attributes
attributes.update(self.validated_data.get("attributes", {}))
self.validated_data["attributes"] = attributes
return super().save(**kwargs)
class Meta:
model = User