Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Secure field
Jakub Draganek6e49c18ecbd8
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.pyindex 12643cf6ba..223231e41b 100644--- a/saleor/graphql/account/types.py+++ b/saleor/graphql/account/types.py@@ -268,6 +268,7 @@ class User(CountableDjangoObjectType):return resolve_payment_sources(root)@staticmethod+ @permission_required("account.manage_users")def resolve_private_meta(root: models.User, _info):return [{"label": label, "metadata": data}diff --git a/tests/api/test_account_meta.py b/tests/api/test_account_meta.pyindex a41e9baad9..4c8398774b 100644--- a/tests/api/test_account_meta.py+++ b/tests/api/test_account_meta.py@@ -1,4 +1,5 @@import graphene+import jsonimport pytestfrom tests.api.utils import get_graphql_content@@ -48,3 +49,29 @@ def test_get_private_meta(assert meta["clients"] == [{"metadata": [{"key": KEY, "value": VALUE}], "name": META_CLIENT}]+++MY_PRIVATE_META_QUERY = """+ {+ me {+ privateMeta {+ label+ clients {+ name+ metadata {+ key+ value+ }+ }+ }+ }+ }+"""+++def test_user_has_no_access_to_private_meta(user_api_client, customer_with_meta):+ response = user_api_client.post_graphql(MY_PRIVATE_META_QUERY)+ data = json.loads(response.content.decode("utf8"))+ assert data["errors"] is not None+ assert data["data"]["me"]["privateMeta"] is None