Adds a log message when an API call raises an InvalidAuthenticityToken error.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3332 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-01-17 20:23:06 +00:00
parent 002f440bcd
commit 0ef9bc039d
1 changed files with 7 additions and 0 deletions

View 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