diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2014-06-18 10:57:40 +0200 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2016-01-27 01:50:40 +0100 |
commit | fbbd3bdaafc0bd442a9120bf4eebb9fbdcaca8fd (patch) | |
tree | d74e89891803432b332c405bfc8fc411a355d2ed | |
parent | cbea42aab6b87905935e28bb2b30184eceef846d (diff) | |
download | ecs2-fbbd3bdaafc0bd442a9120bf4eebb9fbdcaca8fd.tar.gz ecs2-fbbd3bdaafc0bd442a9120bf4eebb9fbdcaca8fd.zip |
Check if json_data is a hash.
-rw-r--r-- | app/controllers/subparticipants_controller.rb | 3 | ||||
-rw-r--r-- | app/models/subparticipant.rb | 1 |
2 files changed, 3 insertions, 1 deletions
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?)?'<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 |