From fbbd3bdaafc0bd442a9120bf4eebb9fbdcaca8fd Mon Sep 17 00:00:00 2001 From: Heiko Bernloehr Date: Wed, 18 Jun 2014 10:57:40 +0200 Subject: Check if json_data is a hash. --- app/controllers/subparticipants_controller.rb | 3 ++- app/models/subparticipant.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/subparticipants_controller.rb b/app/controllers/subparticipants_controller.rb index 4d1b3af..a96d399 100644 --- a/app/controllers/subparticipants_controller.rb +++ b/app/controllers/subparticipants_controller.rb @@ -52,9 +52,10 @@ class SubparticipantsController < ApplicationController sender= @participant begin json_data= ActiveSupport::JSON.decode request.raw_post - rescue StandardError + rescue ActiveSupport::OkJson::Error, StandardError raise Ecs::InvalidMessageException, "You have provided invalid JSON data (SubparticipantsController#create)." end unless request.raw_post.empty? + logger.debug "request raw post: #{(request.raw_post.empty?)?'':request.raw_post}" subparticipant= Subparticipant.generate(sender, json_data) body= show_render(subparticipant) respond_to do |format| diff --git a/app/models/subparticipant.rb b/app/models/subparticipant.rb index c764b33..7bd81f0 100644 --- a/app/models/subparticipant.rb +++ b/app/models/subparticipant.rb @@ -74,6 +74,7 @@ private end def self.process_json_data(sender, json_data) + json_data= {} unless json_data.class == Hash realm= json_data["realm"] ||= nil community_selfrouting= json_data["community_selfrouting"] || false events= json_data["events"] ||= false -- cgit v1.2.3