From e0d9443141884f13a2d4aa69deac1becd5ae3184 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 5 Oct 2017 16:47:52 -0700 Subject: [PATCH] Ensuring existing users are also given the default role. (#960) --- lemur/auth/views.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lemur/auth/views.py b/lemur/auth/views.py index 251fdacc..c5af7606 100644 --- a/lemur/auth/views.py +++ b/lemur/auth/views.py @@ -218,16 +218,18 @@ class Ping(Resource): if not role: role = role_service.create(profile['email'], description='This is a user specific role') + roles.append(role) + # every user is an operator (tied to a default role) + if current_app.config.get('LEMUR_DEFAULT_ROLE'): + default = role_service.get_by_name(current_app.config['LEMUR_DEFAULT_ROLE']) + if not default: + default = role_service.create(current_app.config['LEMUR_DEFAULT_ROLE'], description='This is the default Lemur role.') + roles.append(default) + # if we get an sso user create them an account if not user: - # every user is an operator (tied to a default role) - if current_app.config.get('LEMUR_DEFAULT_ROLE'): - v = role_service.get_by_name(current_app.config.get('LEMUR_DEFAULT_ROLE')) - if v: - roles.append(v) - user = user_service.create( profile['email'], get_psuedo_random_string(), @@ -249,7 +251,7 @@ class Ping(Resource): profile['email'], profile['email'], True, - profile.get('thumbnailPhotoUrl'), # incase profile isn't google+ enabled + profile.get('thumbnailPhotoUrl'), # profile isn't google+ enabled roles )