Introducing public and private extension_props for users

- public: they will be visible to the world (for example as result of the User.find() query)
- private: visible only to their user
This commit is contained in:
2017-10-06 00:13:22 +02:00
parent 98527c72f4
commit be4ce024f4
2 changed files with 12 additions and 6 deletions

View File

@@ -129,11 +129,17 @@ users_schema = {
}
},
# Properties defined by extensions. Extensions should use their name
# (see the PillarExtension.name property) as the key, and are free to
# use whatever they want as value (but we suggest a dict for future
# extendability).
'extension_props': {
# Properties defined by extensions. Extensions should use their name (see the
# PillarExtension.name property) as the key, and are free to use whatever they want as value,
# but we suggest a dict for future extendability.
# Properties can be of two types:
# - public: they will be visible to the world (for example as part of the User.find() query)
# - private: visible only to their user
'extension_props_public': {
'type': 'dict',
'required': False,
},
'extension_props_private': {
'type': 'dict',
'required': False,
},

View File

@@ -135,7 +135,7 @@ def after_fetching_user(user):
return
# Remove all fields except public ones.
public_fields = {'full_name', 'username', 'email'}
public_fields = {'full_name', 'username', 'email', 'extension_props_public'}
for field in list(user.keys()):
if field not in public_fields:
del user[field]