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:
@@ -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,
|
||||
},
|
||||
|
@@ -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]
|
||||
|
Reference in New Issue
Block a user