Add a feature flag for disabling all emails

This commit is contained in:
Joseph Schorr 2014-09-22 19:11:48 -04:00
parent dc685b2387
commit f3b03ebc34
10 changed files with 71 additions and 32 deletions

View file

@ -93,7 +93,7 @@ def hash_password(password, salt=None):
def is_create_user_allowed():
return True
def create_user(username, password, email):
def create_user(username, password, email, auto_verify=False):
""" Creates a regular user, if allowed. """
if not validate_password(password):
raise InvalidPasswordException(INVALID_PASSWORD_MESSAGE)
@ -102,11 +102,8 @@ def create_user(username, password, email):
raise TooManyUsersException()
created = _create_user(username, email)
# Store the password hash
pw_hash = hash_password(password)
created.password_hash = pw_hash
created.password_hash = hash_password(password)
created.verified = auto_verify
created.save()
return created
@ -343,12 +340,11 @@ def remove_team(org_name, team_name, removed_by_username):
team.delete_instance(recursive=True, delete_nullable=True)
def add_or_invite_to_team(inviter, team, user=None, email=None):
def add_or_invite_to_team(inviter, team, user=None, email=None, requires_invite=True):
# If the user is a member of the organization, then we simply add the
# user directly to the team. Otherwise, an invite is created for the user/email.
# We return None if the user was directly added and the invite object if the user was invited.
requires_invite = True
if user:
if user and requires_invite:
orgname = team.organization.username
# If the user is part of the organization (or a robot), then no invite is required.
@ -833,9 +829,9 @@ def change_invoice_email(user, invoice_email):
user.save()
def update_email(user, new_email):
def update_email(user, new_email, auto_verify=False):
user.email = new_email
user.verified = False
user.verified = auto_verify
user.save()