Don't fail if googleGroups is not found in user profile

This commit is contained in:
Jose Plana 2019-05-01 01:15:52 +02:00
parent dfadcc52ef
commit deed1b9685
1 changed files with 10 additions and 7 deletions

View File

@ -129,13 +129,16 @@ def create_user_roles(profile):
roles = [] roles = []
# update their google 'roles' # update their google 'roles'
for group in profile['googleGroups']: if 'googleGroups' in profile:
role = role_service.get_by_name(group) for group in profile['googleGroups']:
if not role: role = role_service.get_by_name(group)
role = role_service.create(group, description='This is a google group based role created by Lemur', third_party=True) if not role:
if not role.third_party: role = role_service.create(group, description='This is a google group based role created by Lemur', third_party=True)
role = role_service.set_third_party(role.id, third_party_status=True) if not role.third_party:
roles.append(role) role = role_service.set_third_party(role.id, third_party_status=True)
roles.append(role)
else:
current_app.logger.warning("'googleGroups' not sent by identity provider, no specific roles will assigned to the user.")
role = role_service.get_by_name(profile['email']) role = role_service.get_by_name(profile['email'])