Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

users: Use a less generic response for unauthorized user creation.

Zixuan James Lia5cc3c5d45cc
diff --git a/zerver/tests/test_example.py b/zerver/tests/test_example.py
index ca409b892df..e43205c2e76 100644
--- a/zerver/tests/test_example.py
+++ b/zerver/tests/test_example.py
@@ -196,7 +196,7 @@ class TestFullStack(ZulipTestCase):
# We often use assert_json_error for negative tests.
result = self.client_post("/json/users", valid_params)
- self.assert_json_error(result, "User not authorized for this query", 400)
+ self.assert_json_error(result, "User not authorized to create users", 400)
do_change_can_create_users(iago, True)
incomplete_params = dict(
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index 7ddfb6637c3..acc31ed0488 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -878,7 +878,7 @@ class AdminCreateUserTest(ZulipTestCase):
self.assertEqual(admin.can_create_users, False)
result = self.client_post("/json/users", valid_params)
- self.assert_json_error(result, "User not authorized for this query")
+ self.assert_json_error(result, "User not authorized to create users")
do_change_can_create_users(admin, True)
# can_create_users is insufficient without being a realm administrator:
diff --git a/zerver/views/users.py b/zerver/views/users.py
index 2ac69c54b96..8fd247fcb81 100644
--- a/zerver/views/users.py
+++ b/zerver/views/users.py
@@ -683,7 +683,7 @@ def create_user_backend(
full_name_raw: str = REQ("full_name"),
) -> HttpResponse:
if not user_profile.can_create_users:
- raise JsonableError(_("User not authorized for this query"))
+ raise JsonableError(_("User not authorized to create users"))
full_name = check_full_name(full_name_raw)
form = CreateUserForm({"full_name": full_name, "email": email})