mirror of https://github.com/zulip/zulip.git
create_user_if_needed: Use proper initial passwords
(imported from commit 009208ac64548dd6f8773ccc7738ab0c391d816a)
This commit is contained in:
parent
f7400fc8b4
commit
b9e9938197
|
@ -232,7 +232,7 @@ def restore_saved_messages():
|
|||
if not realm:
|
||||
realm = Realm.objects.get(domain='mit.edu')
|
||||
|
||||
create_user_if_needed(realm, sender_email, sender_email.split('@')[0],
|
||||
create_user_if_needed(realm, sender_email,
|
||||
old_message["sender_full_name"],
|
||||
old_message["sender_short_name"])
|
||||
message.sender = UserProfile.objects.get(user__email=old_message["sender_email"])
|
||||
|
@ -244,8 +244,7 @@ def restore_saved_messages():
|
|||
|
||||
if message.type == Recipient.PERSONAL:
|
||||
u = old_message["recipient"][0]
|
||||
create_user_if_needed(realm, u["email"], u["email"].split('@')[0],
|
||||
u["full_name"], u["short_name"])
|
||||
create_user_if_needed(realm, u["email"], u["full_name"], u["short_name"])
|
||||
user_profile = UserProfile.objects.get(user__email=u["email"])
|
||||
message.recipient = Recipient.objects.get(type=Recipient.PERSONAL,
|
||||
type_id=user_profile.id)
|
||||
|
@ -255,8 +254,7 @@ def restore_saved_messages():
|
|||
type_id=stream.id)
|
||||
elif message.type == Recipient.HUDDLE:
|
||||
for u in old_message["recipient"]:
|
||||
create_user_if_needed(realm, u["email"], u["email"].split('@')[0],
|
||||
u["full_name"], u["short_name"])
|
||||
create_user_if_needed(realm, u["email"], u["full_name"], u["short_name"])
|
||||
target_huddle = get_huddle([UserProfile.objects.get(user__email=u["email"]).id
|
||||
for u in old_message["recipient"]])
|
||||
message.recipient = Recipient.objects.get(type=Recipient.HUDDLE,
|
||||
|
|
|
@ -5,7 +5,7 @@ import hashlib
|
|||
import base64
|
||||
import calendar
|
||||
from zephyr.lib.cache import cache_with_key
|
||||
from zephyr.lib.initial_password import initial_api_key
|
||||
from zephyr.lib.initial_password import initial_password, initial_api_key
|
||||
import fcntl
|
||||
import os
|
||||
import simplejson
|
||||
|
@ -122,12 +122,12 @@ def create_user(email, password, realm, full_name, short_name):
|
|||
user.save()
|
||||
UserProfile.create(user, realm, full_name, short_name)
|
||||
|
||||
def create_user_if_needed(realm, email, password, full_name, short_name):
|
||||
def create_user_if_needed(realm, email, full_name, short_name):
|
||||
try:
|
||||
return User.objects.get(email=email)
|
||||
except User.DoesNotExist:
|
||||
# forge a user for this person
|
||||
create_user(email, password, realm,
|
||||
create_user(email, initial_password(email), realm,
|
||||
full_name, short_name)
|
||||
user = User.objects.get(email=email)
|
||||
return user
|
||||
|
|
|
@ -338,7 +338,7 @@ def already_sent_forged_message(request):
|
|||
def create_forged_message_users(request, user_profile):
|
||||
# Create a user for the sender, if needed
|
||||
email = request.POST['sender'].lower()
|
||||
user = create_user_if_needed(user_profile.realm, email, "test",
|
||||
user = create_user_if_needed(user_profile.realm, email,
|
||||
request.POST['fullname'],
|
||||
request.POST['shortname'])
|
||||
|
||||
|
@ -347,12 +347,12 @@ def create_forged_message_users(request, user_profile):
|
|||
if ',' in request.POST['recipient']:
|
||||
# Huddle message
|
||||
for user_email in [e.strip() for e in request.POST["recipient"].split(",")]:
|
||||
create_user_if_needed(user_profile.realm, user_email, "test",
|
||||
create_user_if_needed(user_profile.realm, user_email,
|
||||
user_email.split('@')[0],
|
||||
user_email.split('@')[0])
|
||||
else:
|
||||
user_email = request.POST["recipient"].strip()
|
||||
create_user_if_needed(user_profile.realm, user_email, "test",
|
||||
create_user_if_needed(user_profile.realm, user_email,
|
||||
user_email.split('@')[0],
|
||||
user_email.split('@')[0])
|
||||
return user
|
||||
|
|
Loading…
Reference in New Issue