Skip to content

Commit

Permalink
Hide incident email to non-admins
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoCeratto authored and Federico Ceratto committed Oct 16, 2023
1 parent dd0e77c commit 72c8d3c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/ooniapi/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def search_list_incidents() -> Response:
rows = list(q)
for r in rows:
r["published"] = bool(r["published"])
if account_id is None or get_client_role() != "admin":
r["email_address"] = None # hide email
return nocachejson(incidents=rows, v=1)
except BaseOONIException as e:
return jerror(e)
Expand Down Expand Up @@ -140,6 +142,8 @@ def show_incident(incident_id: str) -> Response:
return jerror("Not found")
inc = q[0]
inc["published"] = bool(inc["published"])
if account_id is None or get_client_role() != "admin":
inc["email_address"] = None # hide email
# TODO: cache if possible
return nocachejson(incident=inc, v=1)
except BaseOONIException as e:
Expand Down

0 comments on commit 72c8d3c

Please sign in to comment.