Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
auth: Check spare licenses against the invited role during signup.
Alex Vandiver1df72449f36c
diff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex acad15c3cd1..fe5b94b7d9a 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -264,6 +264,22 @@ def maybe_send_to_registration(else:invited_as = PreregistrationUser.INVITE_AS["MEMBER"]+ try:+ # If there's an existing, valid PreregistrationUser for this+ # user, we want to fetch it since some values from it will be used+ # as defaults for creating the signed up user.+ existing_prereg_user = filter_to_valid_prereg_users(+ PreregistrationUser.objects.filter(email__iexact=email, realm=realm)+ ).latest("invited_at")+ except PreregistrationUser.DoesNotExist:+ existing_prereg_user = None++ if multiuse_obj is None and existing_prereg_user is not None:+ # When the user is not signing up via a multiuse invite link,+ # the existing PreregistrationUser tells us the role they were+ # intended to have, when they were invited.+ invited_as = existing_prereg_user.invited_as+form = HomepageForm({"email": email},realm=realm,@@ -276,19 +292,10 @@ def maybe_send_to_registration(# Confirmation objects, and then send the user to account# creation or confirm-continue-registration depending on# is_signup.- try:- # If there's an existing, valid PreregistrationUser for this- # user, we want to fetch it since some values from it will be used- # as defaults for creating the signed up user.- existing_prereg_user = filter_to_valid_prereg_users(- PreregistrationUser.objects.filter(email__iexact=email, realm=realm)- ).latest("invited_at")- except PreregistrationUser.DoesNotExist:- existing_prereg_user = None-+ ## full_name data passed here as argument should take precedence- # over the defaults with which the existing PreregistrationUser that we've just fetched- # was created.+ # over the defaults with which the existing PreregistrationUser+ # fetched above was created.prereg_user = create_preregistration_user(email,realm,@@ -316,7 +323,6 @@ def maybe_send_to_registration(include_realm_default_subscriptions = (existing_prereg_user.include_realm_default_subscriptions)- invited_as = existing_prereg_user.invited_asif streams_to_subscribe:prereg_user.streams.set(streams_to_subscribe)