Call process_new_human_user consistently when creating new users.

Previously we only did this when new human users were created via the
login process, which meant the management command to create a user did
not add the user to default streams (for example) and any future code
that might want to register a new Zulip user (such as the LDAP
integration) would need to import views/__init__.py in order to
properly set this up.
This commit is contained in:
Tim Abbott
2015-10-13 15:33:54 -04:00
parent 355e1bbd94
commit 90e61d3b61
2 changed files with 13 additions and 9 deletions

View File

@@ -250,7 +250,8 @@ def do_create_user(email, password, realm, full_name, short_name,
active=True, bot=False, bot_owner=None,
avatar_source=UserProfile.AVATAR_FROM_GRAVATAR,
default_sending_stream=None, default_events_register_stream=None,
default_all_public_streams=None):
default_all_public_streams=None, prereg_user=None,
newsletter_data=None):
event = {'type': 'user_created',
'timestamp': time.time(),
'full_name': full_name,
@@ -273,6 +274,9 @@ def do_create_user(email, password, realm, full_name, short_name,
notify_created_user(user_profile)
if bot:
notify_created_bot(user_profile)
else:
process_new_human_user(user_profile, prereg_user=prereg_user,
newsletter_data=newsletter_data)
return user_profile
def user_sessions(user_profile):

View File

@@ -29,7 +29,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, Huddle, \
from zerver.lib.actions import bulk_remove_subscriptions, do_change_password, \
do_change_full_name, do_change_enable_desktop_notifications, do_change_is_admin, \
do_change_enter_sends, do_change_enable_sounds, do_activate_user, do_create_user, \
process_new_human_user, do_change_subscription_property, internal_send_message, \
do_change_subscription_property, internal_send_message, \
create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \
update_user_presence, bulk_add_subscriptions, do_events_register, \
get_status_dict, do_change_enable_offline_email_notifications, \
@@ -296,12 +296,13 @@ def accounts_register(request):
do_change_password(user_profile, password)
do_change_full_name(user_profile, full_name)
except UserProfile.DoesNotExist:
user_profile = do_create_user(email, password, realm, full_name, short_name)
user_profile = do_create_user(email, password, realm, full_name, short_name,
prereg_user=prereg_user,
newsletter_data={"IP": request.META['REMOTE_ADDR']})
else:
user_profile = do_create_user(email, password, realm, full_name, short_name)
process_new_human_user(user_profile, prereg_user=prereg_user,
newsletter_data={"IP": request.META['REMOTE_ADDR']})
user_profile = do_create_user(email, password, realm, full_name, short_name,
prereg_user=prereg_user,
newsletter_data={"IP": request.META['REMOTE_ADDR']})
# This logs you in using the ZulipDummyBackend, since honestly nothing
# more fancy than this is required.
@@ -1639,8 +1640,7 @@ def create_user_backend(request, user_profile, email=REQ, password=REQ,
except UserProfile.DoesNotExist:
pass
new_user_profile = do_create_user(email, password, realm, full_name, short_name)
process_new_human_user(new_user_profile)
do_create_user(email, password, realm, full_name, short_name)
return json_success()
@authenticated_json_post_view