From 6b451ce6f0a032abb808fe619de99d8afe554158 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Mon, 18 Jul 2022 11:12:07 +0200 Subject: [PATCH] create_user: Remove assert about needing prereg_user if realm_creation. Closes #22274. This assertion was added in 4b903c5dcdf3ea236a289f6d204b2953d11445c7 where it may have made sense, because indeed when doing realm creation there was always a PreregistrationUser (created because realms were created via going to a generated realm creation link). With the addition of the create_realm command that's no longer the case. It would be unnatural to create a PreregistrationUser in the realm_creation command, because there is no confirmation link for it to be tied to - and it just doesn't make sense conceptually. The intended, correct behavior added in 4b903c5dcdf3ea236a289f6d204b2953d11445c7 is still maintained - the code lower down correctly handles the (prereg_user is None and realm_creation) case. --- zerver/actions/create_user.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.py index d92d87fcbd..eaf06abf7f 100644 --- a/zerver/actions/create_user.py +++ b/zerver/actions/create_user.py @@ -237,8 +237,6 @@ def process_new_human_user( # Revoke all preregistration users except prereg_user, and link prereg_user to # the created user - if prereg_user is None: - assert not realm_creation, "realm_creation should only happen with a PreregistrationUser" if prereg_user is not None: prereg_user.status = confirmation_settings.STATUS_ACTIVE