Skip to content

Commit

Permalink
Update the claim configs
Browse files Browse the repository at this point in the history
  • Loading branch information
dinukadesilva committed Nov 2, 2019
1 parent cf49272 commit 7d2abef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def get_user_name() -> str:
"""
return connexion.context[USER_NAME]


def get_user_roles():
return connexion.context[USER_ROLES]

Expand Down Expand Up @@ -229,17 +230,20 @@ def authorize(func, required_roles=None, *args, **kwargs):
user_access_area_ids.extend([x.get(AREA_ID) for x in claims.get(claim)])

if role is DATA_EDITOR_ROLE:
counting_centre_ids = []
global_area_map = init_global_area_map()
for electoral_district_id in user_access_area_ids:
if electoral_district_id in global_area_map["electoral_district_counting_centre"]:
user_access_area_ids.extend(
counting_centre_ids.extend(
global_area_map["electoral_district_counting_centre"][electoral_district_id]
)

elif role is POLLING_DIVISION_REPORT_VIEWER_ROLE or role is POLLING_DIVISION_REPORT_VERIFIER_ROLE:
counting_centre_ids = []
global_area_map = init_global_area_map()
for electoral_district_id in user_access_area_ids:
if electoral_district_id in global_area_map["electoral_district_polling_division"]:
user_access_area_ids.extend(
counting_centre_ids.extend(
global_area_map["electoral_district_polling_division"][electoral_district_id]
)

Expand Down

0 comments on commit 7d2abef

Please sign in to comment.