Add feature flag to allow users to be created only if invited to join a team

Allows for open user creation, but only if extended an invitation by someone who already has access
This commit is contained in:
Joseph Schorr 2017-09-14 15:34:41 -04:00
parent c44cc072fa
commit 804d3c46c3
8 changed files with 112 additions and 4 deletions

18
data/users/shared.py Normal file
View file

@ -0,0 +1,18 @@
import features
from data import model
def can_create_user(email_address):
""" Returns true if a user with the specified e-mail address can be created. """
if not features.USER_CREATION:
return False
if features.INVITE_ONLY_USER_CREATION:
if not email_address:
return False
# Check to see that there is an invite for the e-mail address.
return bool(model.team.lookup_team_invites_by_email(email_address))
# Otherwise the user can be created (assuming it doesn't already exist, of course)
return True