stages/user_write: fix data being saved as attributes without intent

This commit is contained in:
Jens Langhammer 2020-09-18 18:15:33 +02:00
parent ddc1022461
commit d6cc6770b8
1 changed files with 5 additions and 1 deletions

View File

@ -51,8 +51,12 @@ class UserWriteStageView(StageView):
# User has this key already # User has this key already
elif hasattr(user, key): elif hasattr(user, key):
setattr(user, key, value) setattr(user, key, value)
# Otherwise we just save it as custom attribute # Otherwise we just save it as custom attribute, but only if the value is prefixed with
# `attribute_`, to prevent accidentally saving values
else: else:
if not key.startswith("attribute_"):
LOGGER.debug("discarding key", key=key)
continue
user.attributes[key] = value user.attributes[key] = value
user.save() user.save()
user_write.send(sender=self, request=request, user=user, data=data) user_write.send(sender=self, request=request, user=user, data=data)