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

@ -69,7 +69,6 @@ class OrganizationList(ApiResource):
'description': 'Description of a new organization.',
'required': [
'name',
'email',
],
'properties': {
'name': {
@ -105,8 +104,12 @@ class OrganizationList(ApiResource):
msg = 'A user or organization with this name already exists'
raise request_error(message=msg)
if features.MAILING and not org_data.get('email'):
raise request_error(message='Email address is required')
try:
model.organization.create_organization(org_data['name'], org_data['email'], user)
model.organization.create_organization(org_data['name'], org_data.get('email'), user,
email_required=features.MAILING)
return 'Created', 201
except model.DataModelException as ex:
raise request_error(exception=ex)