Skip to content

Commit 67c14f9

Browse files
fix: problem of two-step flow find and authorize (#344)
1 parent c77149b commit 67c14f9

File tree

20 files changed

+166
-35
lines changed

20 files changed

+166
-35
lines changed

app/controllers/api/v1/event_procedures_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def event_procedure_params
111111
end
112112

113113
def event_procedure
114-
@event_procedure ||= EventProcedures::Find.result(id: params[:id]).event_procedure
114+
@event_procedure ||= EventProcedures::Find.result(
115+
id: params[:id],
116+
scope: policy_scope(EventProcedure)
117+
).event_procedure
115118
end
116119

117120
def serialized_event_procedures(event_procedures)

app/controllers/api/v1/hospitals_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ def destroy
4848
private
4949

5050
def hospital
51-
@hospital ||= Hospitals::Find.result(id: params[:id]).hospital
51+
@hospital ||= Hospitals::Find.result(
52+
id: params[:id],
53+
scope: policy_scope(Hospital)
54+
).hospital
5255
end
5356

5457
def hospital_params

app/controllers/api/v1/medical_shifts_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def destroy
8080
private
8181

8282
def medical_shift
83-
@medical_shift ||= MedicalShifts::Find.result(id: params[:id]).medical_shift
83+
@medical_shift ||= MedicalShifts::Find.result(
84+
id: params[:id],
85+
scope: policy_scope(MedicalShift)
86+
).medical_shift
8487
end
8588

8689
def medical_shift_params

app/controllers/api/v1/patients_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def destroy
5252
private
5353

5454
def patient
55-
@patient ||= Patients::Find.result(id: params[:id]).patient
55+
@patient ||= Patients::Find.result(
56+
id: params[:id],
57+
scope: policy_scope(Patient)
58+
).patient
5659
end
5760

5861
def patient_params

app/controllers/api/v1/procedures_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def destroy
5050
private
5151

5252
def procedure
53-
@procedure ||= Procedures::Find.result(id: params[:id]).procedure
53+
@procedure ||= Procedures::Find.result(
54+
id: params[:id],
55+
scope: policy_scope(Procedure)
56+
).procedure
5457
end
5558

5659
def procedure_params

app/operations/event_procedures/find.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
module EventProcedures
44
class Find < Actor
55
input :id, type: String
6+
input :scope, type: Enumerable, default: -> { EventProcedure.all }
67

78
output :event_procedure, type: EventProcedure
89

910
def call
10-
self.event_procedure = EventProcedure.find(id)
11+
self.event_procedure = scope.find(id)
1112
end
1213
end
1314
end

app/operations/hospitals/find.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
module Hospitals
44
class Find < Actor
55
input :id, type: String
6+
input :scope, type: Enumerable, default: -> { Hospital.all }
67

78
output :hospital, type: Hospital
89

910
def call
10-
self.hospital = Hospital.find(id)
11+
self.hospital = scope.find(id)
1112
end
1213
end
1314
end

app/operations/medical_shifts/find.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
module MedicalShifts
44
class Find < Actor
55
input :id, type: String
6+
input :scope, type: Enumerable, default: -> { MedicalShift.all }
67

78
output :medical_shift, type: MedicalShift
89

910
def call
10-
self.medical_shift = MedicalShift.find(id)
11+
self.medical_shift = scope.find(id)
1112
end
1213
end
1314
end

app/operations/patients/find.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
module Patients
44
class Find < Actor
55
input :id, type: String
6+
input :scope, type: Enumerable, default: -> { Patient.all }
67

78
output :patient, type: Patient
89

910
def call
10-
self.patient = Patient.find(id)
11+
self.patient = scope.find(id)
1112
end
1213
end
1314
end

app/operations/procedures/find.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
module Procedures
44
class Find < Actor
55
input :id, type: String
6+
input :scope, type: Enumerable, default: -> { Procedure.all }
67

78
output :procedure, type: Procedure
89

910
def call
10-
self.procedure = Procedure.find(id)
11+
self.procedure = scope.find(id)
1112
end
1213
end
1314
end

0 commit comments

Comments
 (0)