demarches-normaliennes/app/controllers/api/v1/procedures_controller.rb
2019-03-12 11:59:01 +01:00

20 lines
488 B
Ruby

class API::V1::ProceduresController < APIController
before_action :fetch_procedure_and_check_token
def show
render json: { procedure: ProcedureSerializer.new(@procedure).as_json }
end
private
def fetch_procedure_and_check_token
@procedure = Procedure.for_api.find(params[:id])
if !valid_token_for_procedure?(@procedure)
render json: {}, status: :unauthorized
end
rescue ActiveRecord::RecordNotFound
render json: {}, status: :not_found
end
end