invites: Only admins should be able to create multiuse invites.

This commit is contained in:
Vishnu Ks 2018-03-02 22:46:08 +05:30 committed by Tim Abbott
parent 5069683cad
commit f0d651f9fe
2 changed files with 4 additions and 2 deletions

View File

@ -1137,7 +1137,9 @@ class MultiuseInviteTest(ZulipTestCase):
def test_only_admin_can_create_multiuse_link_api_call(self) -> None:
self.login(self.example_email('iago'))
self.realm.invite_by_admins_only = True
# Only admins should be able to create multiuse invites even if
# invite_by_admins_only is set to False.
self.realm.invite_by_admins_only = False
self.realm.save()
result = self.client_post('/json/invites/multiuse')

View File

@ -101,7 +101,7 @@ def resend_user_invite_email(request: HttpRequest, user_profile: UserProfile,
def generate_multiuse_invite_backend(request: HttpRequest, user_profile: UserProfile,
stream_ids: List[int]=REQ(validator=check_list(check_int),
default=[])) -> HttpResponse:
if user_profile.realm.invite_by_admins_only and not user_profile.is_realm_admin:
if not user_profile.is_realm_admin:
return json_error(_("Must be a realm administrator"))
streams = []