registration: Tie PreregistrationUser to the original MultiUseInvite.

Fixes #21266.

We want to tie the prereg_user to the MultiUseInvite directly rather
than to the MultiUserInvite's confirmation object, because the latter is
not possible. This is because the flow is that after going through the
multiuse invite link, the PreregistrationUser is created together with a
Confirmation object, creating a confirmation link (via
create_confirmation_link) to which then the user is redirected to finish
account creation. This means that the PreregistrationUser is already
tied to a Confirmation, so that attribute is occupied.
This commit is contained in:
Mateusz Mandera
2022-07-21 23:38:59 +02:00
committed by Tim Abbott
parent 5697c047fc
commit 39d8a81e51
6 changed files with 46 additions and 1 deletions

View File

@@ -1606,6 +1606,11 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase, ABC):
result, realm, subdomain, email, name, name, self.BACKEND_CLASS.full_name_validated
)
# Verify the PreregistrationUser object was set up as expected.
prereg_user = PreregistrationUser.objects.last()
self.assertEqual(prereg_user.email, email)
self.assertEqual(prereg_user.multiuse_invite, multiuse_obj)
@override_settings(TERMS_OF_SERVICE_VERSION=None)
def test_social_auth_registration_using_multiuse_invite_realm_validation(self) -> None:
"""If the user doesn't exist yet, social auth can be used to register an account"""