Added username to public user fields
This commit is contained in:
@@ -102,7 +102,7 @@ def after_fetching_user(user):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Remove all fields except public ones.
|
# Remove all fields except public ones.
|
||||||
public_fields = {'full_name', 'email'}
|
public_fields = {'full_name', 'username', 'email'}
|
||||||
for field in list(user.keys()):
|
for field in list(user.keys()):
|
||||||
if field not in public_fields:
|
if field not in public_fields:
|
||||||
del user[field]
|
del user[field]
|
||||||
|
@@ -9,9 +9,9 @@ from pillar.web.system_util import pillar_api
|
|||||||
|
|
||||||
|
|
||||||
def get_user_info(user_id):
|
def get_user_info(user_id):
|
||||||
"""Returns email & full name of the user.
|
"""Returns email, username and full name of the user.
|
||||||
|
|
||||||
Only returns those two fields, so the return value is the same
|
Only returns the public fields, so the return value is the same
|
||||||
for authenticated & non-authenticated users, which is why we're
|
for authenticated & non-authenticated users, which is why we're
|
||||||
allowed to cache it globally.
|
allowed to cache it globally.
|
||||||
|
|
||||||
@@ -26,7 +26,8 @@ def get_user_info(user_id):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
return {'email': user.email,
|
return {'email': user.email,
|
||||||
'full_name': user.full_name}
|
'full_name': user.full_name,
|
||||||
|
'username': user.username}
|
||||||
|
|
||||||
|
|
||||||
def setup_app(app):
|
def setup_app(app):
|
||||||
|
@@ -11,7 +11,7 @@ from pillar.tests import AbstractPillarTest, TEST_EMAIL_USER, TEST_EMAIL_ADDRESS
|
|||||||
from pillar.tests.common_test_data import EXAMPLE_NODE
|
from pillar.tests.common_test_data import EXAMPLE_NODE
|
||||||
from werkzeug.exceptions import Forbidden
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
PUBLIC_USER_FIELDS = {'full_name', 'email'}
|
PUBLIC_USER_FIELDS = {'full_name', 'email', 'username'}
|
||||||
|
|
||||||
# Use the example project with some additional permissions for these tests.
|
# Use the example project with some additional permissions for these tests.
|
||||||
EXAMPLE_PROJECT = copy.deepcopy(ctd.EXAMPLE_PROJECT)
|
EXAMPLE_PROJECT = copy.deepcopy(ctd.EXAMPLE_PROJECT)
|
||||||
|
Reference in New Issue
Block a user