2015-12-21 17:51:49 +01:00
|
|
|
class API::V1::ProceduresController < APIController
|
2018-09-26 16:38:35 +02:00
|
|
|
before_action :fetch_procedure_and_check_token
|
|
|
|
|
2016-02-02 18:11:44 +01:00
|
|
|
def show
|
2018-10-22 19:24:38 +02:00
|
|
|
render json: { procedure: ProcedureSerializer.new(@procedure).as_json }
|
2018-09-26 16:38:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_procedure_and_check_token
|
2018-11-01 14:04:32 +01:00
|
|
|
@procedure = Procedure.for_api.find(params[:id])
|
2018-09-26 16:38:35 +02:00
|
|
|
|
2019-03-06 15:21:25 +01:00
|
|
|
administrateur = find_administrateur_for_token(@procedure)
|
2023-03-15 17:22:12 +01:00
|
|
|
if administrateur.nil?
|
2018-09-26 16:38:35 +02:00
|
|
|
render json: {}, status: :unauthorized
|
2023-03-15 17:53:45 +01:00
|
|
|
else
|
|
|
|
# allow BaseController append_info_to_payload
|
|
|
|
# to log info on current_user
|
|
|
|
@current_user = administrateur.user
|
2018-09-26 16:38:35 +02:00
|
|
|
end
|
2018-09-26 16:39:10 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
2018-09-26 16:38:35 +02:00
|
|
|
render json: {}, status: :not_found
|
2015-12-21 17:51:49 +01:00
|
|
|
end
|
|
|
|
end
|