OSDN Git Service

Adds a log message when an API call raises an InvalidAuthenticityToken error.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jan 2010 20:23:06 +0000 (20:23 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 17 Jan 2010 20:23:06 +0000 (20:23 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3332 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb

index 9f3169a..16652c8 100644 (file)
@@ -227,6 +227,9 @@ class ApplicationController < ActionController::Base
   end
   
   def invalid_authenticity_token
+    if api_request?
+      logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
+    end
     render_error "Invalid form authenticity token."
   end
   
@@ -308,4 +311,8 @@ class ApplicationController < ActionController::Base
   def filename_for_content_disposition(name)
     request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
   end
+  
+  def api_request?
+    %w(xml json).include? params[:format]
+  end
 end