Allow authenticating with an API token via XML or JSON. (#3920)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3218 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2009-12-23 06:27:33 +00:00
parent aa9951b38b
commit baa1ad4256
3 changed files with 82 additions and 1 deletions
+7 -1
View File
@@ -70,6 +70,8 @@ class ApplicationController < ActionController::Base
elsif params[:format] == 'atom' && params[:key] && accept_key_auth_actions.include?(params[:action])
# RSS key authentication does not start a session
User.find_by_rss_key(params[:key])
elsif ['xml', 'json'].include?(params[:format]) && params[:key] && accept_key_auth_actions.include?(params[:action])
User.find_by_api_key(params[:key])
end
end
@@ -114,7 +116,11 @@ class ApplicationController < ActionController::Base
else
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
end
redirect_to :controller => "account", :action => "login", :back_url => url
respond_to do |format|
format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
format.xml { head :unauthorized }
format.json { head :unauthorized }
end
return false
end
true