diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py index 4d2d1c6f88..13383f9a1d 100644 --- a/zerver/actions/create_realm.py +++ b/zerver/actions/create_realm.py @@ -18,6 +18,7 @@ from zerver.lib.bulk_create import create_users from zerver.lib.push_notifications import sends_notifications_directly from zerver.lib.remote_server import maybe_enqueue_audit_log_upload from zerver.lib.server_initialization import create_internal_realm, server_initialized +from zerver.lib.sessions import delete_realm_user_sessions from zerver.lib.streams import ensure_stream from zerver.lib.user_groups import ( create_system_user_groups_for_realm, @@ -94,6 +95,9 @@ def do_change_realm_subdomain( ) do_add_deactivated_redirect(placeholder_realm, realm.url) + # Sessions can't be deleted inside a transaction. + delete_realm_user_sessions(realm) + def set_realm_permissions_based_on_org_type(realm: Realm) -> None: """This function implements overrides for the default configuration