ldap: Fix realm_creation=True registration flow.

When creating realm with the ldap backend, the registration flow didn't
properly handle some things - the user wouldn't be set as realm admin,
initial subscriptions and messages weren't created, and the redirect
wasn't happening properly in the case of subdomains.
This commit is contained in:
Mateusz Mandera
2019-11-07 05:13:08 +01:00
committed by Tim Abbott
parent 9ca26e91e0
commit ed40d37e44
3 changed files with 22 additions and 5 deletions

View File

@@ -619,9 +619,12 @@ class ZulipLDAPAuthBackend(ZulipLDAPAuthBackendBase):
opts = {} # type: Dict[str, Any]
if self._prereg_user:
invited_as = self._prereg_user.invited_as
realm_creation = self._prereg_user.realm_creation
opts['prereg_user'] = self._prereg_user
opts['is_realm_admin'] = invited_as == PreregistrationUser.INVITE_AS['REALM_ADMIN']
opts['is_realm_admin'] = (
invited_as == PreregistrationUser.INVITE_AS['REALM_ADMIN']) or realm_creation
opts['is_guest'] = invited_as == PreregistrationUser.INVITE_AS['GUEST_USER']
opts['realm_creation'] = realm_creation
opts['default_stream_groups'] = get_default_stream_groups(self._realm)
user_profile = do_create_user(username, None, self._realm, full_name, short_name, **opts)