Make email addresses optional in external auth if email feature is turned off

Before this change, external auth such as Keystone would fail if a user without an email address tried to login, even if the email feature was disabled.
This commit is contained in:
Joseph Schorr 2016-09-08 12:24:47 -04:00
parent 934cdecbd6
commit d7f56350a4
18 changed files with 206 additions and 93 deletions

View file

@ -210,7 +210,7 @@ class SuperUserList(ApiResource):
'CreateInstallUser': {
'id': 'CreateInstallUser',
'description': 'Data for creating a user',
'required': ['username', 'email'],
'required': ['username'],
'properties': {
'username': {
'type': 'string',
@ -253,15 +253,15 @@ class SuperUserList(ApiResource):
user_information = request.get_json()
if SuperUserPermission().can():
username = user_information['username']
email = user_information['email']
# Generate a temporary password for the user.
random = SystemRandom()
password = ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(32)])
# Create the user.
user = model.user.create_user(username, password, email, auto_verify=not features.MAILING)
username = user_information['username']
email = user_information.get('email')
user = model.user.create_user(username, password, email, auto_verify=not features.MAILING,
email_required=features.MAILING)
# If mailing is turned on, send the user a verification email.
if features.MAILING: