mirror of https://github.com/zulip/zulip.git
api: Do not require short_name to create user.
When you post to /json/users, we no longer require or look at the short_name parameter, since we don't use it in any meaningful way. An upcoming commit will eliminate it from the database.
This commit is contained in:
parent
b375581f58
commit
c60f4236a9
|
@ -153,7 +153,7 @@ from zerver.lib.request import has_request_variables, REQ
|
|||
@require_realm_admin
|
||||
@has_request_variables
|
||||
def create_user_backend(request, user_profile, email=REQ(), password=REQ(),
|
||||
full_name=REQ(), short_name=REQ()):
|
||||
full_name=REQ()):
|
||||
# ... code here
|
||||
```
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ below features are supported.
|
|||
|
||||
## Changes in Zulip 3.1
|
||||
|
||||
**Feature level 27**
|
||||
|
||||
* The `short_name` field is removed from `display_recipients`
|
||||
in `POST /users`.
|
||||
|
||||
**Feature level 26**
|
||||
|
||||
* The `sender_short_name` field is no longer included in
|
||||
|
|
|
@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
|||
#
|
||||
# Changes should be accompanied by documentation explaining what the
|
||||
# new level means in templates/zerver/api/changelog.md.
|
||||
API_FEATURE_LEVEL = 26
|
||||
API_FEATURE_LEVEL = 27
|
||||
|
||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||
# only when going from an old version of the code to a newer version. Bump
|
||||
|
|
|
@ -130,7 +130,6 @@ add_example('create_user', '/users:post', 200, async (client) => {
|
|||
email: 'notnewbie@zulip.com',
|
||||
password: 'temp',
|
||||
full_name: 'New User',
|
||||
short_name: 'newbie',
|
||||
};
|
||||
|
||||
return await client.users.create(params);
|
||||
|
|
|
@ -153,7 +153,6 @@ def create_user(client: Client) -> None:
|
|||
'email': 'newbie@zulip.com',
|
||||
'password': 'temp',
|
||||
'full_name': 'New User',
|
||||
'short_name': 'newbie',
|
||||
}
|
||||
result = client.create_user(request)
|
||||
# {code_example|end}
|
||||
|
|
|
@ -1520,14 +1520,6 @@ paths:
|
|||
type: string
|
||||
example: New User
|
||||
required: true
|
||||
- name: short_name
|
||||
in: query
|
||||
description: |
|
||||
The short name of the new user. Not user-visible.
|
||||
schema:
|
||||
type: string
|
||||
example: newuser
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: Success.
|
||||
|
|
|
@ -782,18 +782,19 @@ class AdminCreateUserTest(ZulipTestCase):
|
|||
))
|
||||
self.assert_json_error(result, "Missing 'full_name' argument")
|
||||
|
||||
# Test short_name gets properly ignored
|
||||
result = self.client_post("/json/users", dict(
|
||||
email='romeo@not-zulip.com',
|
||||
email='romeo@zulip.com',
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='DEPRECATED'
|
||||
))
|
||||
self.assert_json_error(result, "Missing 'short_name' argument")
|
||||
self.assert_json_success(result)
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
email='broken',
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='Romeo',
|
||||
))
|
||||
self.assert_json_error(result, "Bad name or username")
|
||||
|
||||
|
@ -802,7 +803,6 @@ class AdminCreateUserTest(ZulipTestCase):
|
|||
email='romeo@not-zulip.com',
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='Romeo',
|
||||
))
|
||||
self.assert_json_error(result,
|
||||
"Email 'romeo@not-zulip.com' not allowed in this organization")
|
||||
|
@ -812,7 +812,6 @@ class AdminCreateUserTest(ZulipTestCase):
|
|||
email='romeo@zulip.net',
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='Romeo',
|
||||
)
|
||||
# Check can't use a bad password with zxcvbn enabled
|
||||
with self.settings(PASSWORD_MIN_LENGTH=6, PASSWORD_MIN_GUESSES=1000):
|
||||
|
@ -825,7 +824,7 @@ class AdminCreateUserTest(ZulipTestCase):
|
|||
# Romeo is a newly registered user
|
||||
new_user = get_user_by_delivery_email('romeo@zulip.net', get_realm('zulip'))
|
||||
self.assertEqual(new_user.full_name, 'Romeo Montague')
|
||||
self.assertEqual(new_user.short_name, 'Romeo')
|
||||
self.assertEqual(new_user.short_name, 'deprecated')
|
||||
|
||||
# Make sure the recipient field is set correctly.
|
||||
self.assertEqual(new_user.recipient, Recipient.objects.get(type=Recipient.PERSONAL,
|
||||
|
|
|
@ -486,9 +486,13 @@ def get_members_backend(request: HttpRequest, user_profile: UserProfile, user_id
|
|||
|
||||
@require_realm_admin
|
||||
@has_request_variables
|
||||
def create_user_backend(request: HttpRequest, user_profile: UserProfile,
|
||||
email: str=REQ(), password: str=REQ(), full_name_raw: str=REQ("full_name"),
|
||||
short_name: str=REQ()) -> HttpResponse:
|
||||
def create_user_backend(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
email: str=REQ(),
|
||||
password: str=REQ(),
|
||||
full_name_raw: str=REQ("full_name"),
|
||||
) -> HttpResponse:
|
||||
full_name = check_full_name(full_name_raw)
|
||||
form = CreateUserForm({'full_name': full_name, 'email': email})
|
||||
if not form.is_valid():
|
||||
|
@ -518,6 +522,8 @@ def create_user_backend(request: HttpRequest, user_profile: UserProfile,
|
|||
if not check_password_strength(password):
|
||||
return json_error(PASSWORD_TOO_WEAK_ERROR)
|
||||
|
||||
short_name = 'deprecated'
|
||||
|
||||
do_create_user(email, password, realm, full_name, short_name, acting_user=user_profile)
|
||||
return json_success()
|
||||
|
||||
|
|
Loading…
Reference in New Issue