Also allow demo users access to Flamenco & Attract

This commit is contained in:
2017-08-15 15:25:50 +02:00
parent fd600c9fa0
commit 2e4ed6f3c8
2 changed files with 19 additions and 4 deletions

View File

@@ -91,16 +91,17 @@ class CloudExtension(PillarExtension):
from pillar.api import service
linked_roles = {'flamenco-user', 'attract-user'}
link_to = 'subscriber'
link_to = {'subscriber', 'demo'}
user_roles = set(user.get('roles', []))
# Determine what to do
has_linked_roles = not (linked_roles - user_roles)
has_link_to = bool(link_to.intersection(user_roles))
action = ''
if link_to in user_roles and not has_linked_roles:
if has_link_to and not has_linked_roles:
self._log.info('Granting roles %s to user %s', linked_roles, user['_id'])
action = 'grant'
elif link_to not in user_roles and has_linked_roles:
elif not has_link_to and has_linked_roles:
self._log.info('Revoking roles %s from user %s', linked_roles, user['_id'])
action = 'revoke'