Skip to content

Commit 2533322

Browse files
committed
Fix bugs around user-supplied config not being properly applied
- Fix bug where user selects no parameters for an event type so it reverts to the default - Fix bug where a non-PII user could view PII by modifying the URL
1 parent 51bf616 commit 2533322

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

app/controllers/inspect/timeline/patients_controller.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,26 @@ def build_details_config
124124
Hash
125125
)
126126

127-
details_params.each_with_object({}) do |(event_type, fields), hash|
128-
selected_fields = Array(fields).reject(&:blank?).map(&:to_sym)
129-
hash[event_type.to_sym] = selected_fields
127+
event_list_details =
128+
(@event_names - ["audits"]).map { [it.to_sym, []] }.to_h
129+
user_submitted_details =
130+
details_params.each_with_object(
131+
event_list_details
132+
) do |(event_type, fields), hash|
133+
selected_fields = Array(fields).reject(&:blank?).map(&:to_sym)
134+
hash[event_type.to_sym] = selected_fields
135+
end
136+
137+
details_mask =
138+
(
139+
if @show_pii
140+
TimelineRecords::AVAILABLE_DETAILS_CONFIG_WITH_PII
141+
else
142+
TimelineRecords::AVAILABLE_DETAILS_CONFIG
143+
end
144+
)
145+
(details_mask.keys & user_submitted_details.keys).index_with do |key|
146+
details_mask[key] & user_submitted_details[key]
130147
end
131148
end
132149

0 commit comments

Comments
 (0)