##// END OF EJS Templates
Backported r6197 from trunk....
Jean-Philippe Lang -
r6078:a5bcdf6d2c93
parent child
Show More
@@ -1,7 +1,24
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 18 class ActivitiesController < ApplicationController
2 19 menu_item :activity
3 20 before_filter :find_optional_project
4 accept_key_auth :index
21 accept_rss_auth :index
5 22
6 23 def index
7 24 @days = Setting.activity_days_default.to_i
@@ -71,11 +71,11 class ApplicationController < ActionController::Base
71 71 user = User.try_to_autologin(cookies[:autologin])
72 72 session[:user_id] = user.id if user
73 73 user
74 elsif params[:format] == 'atom' && request.get? && params[:key] && accept_key_auth_actions.include?(params[:action])
74 elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
75 75 # RSS key authentication does not start a session
76 76 User.find_by_rss_key(params[:key])
77 elsif Setting.rest_api_enabled? && api_request?
78 if (key = api_key_from_request) && accept_key_auth_actions.include?(params[:action])
77 elsif Setting.rest_api_enabled? && accept_api_auth?
78 if (key = api_key_from_request)
79 79 # Use API key
80 80 User.find_by_api_key(key)
81 81 else
@@ -332,14 +332,41 class ApplicationController < ActionController::Base
332 332 @title = options[:title] || Setting.app_title
333 333 render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
334 334 end
335
335
336 # TODO: remove in Redmine 1.4
336 337 def self.accept_key_auth(*actions)
337 actions = actions.flatten.map(&:to_s)
338 write_inheritable_attribute('accept_key_auth_actions', actions)
338 ActiveSupport::Deprecaction.warn "ApplicationController.accept_key_auth is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
339 accept_rss_auth(*actions)
339 340 end
340 341
342 # TODO: remove in Redmine 1.4
341 343 def accept_key_auth_actions
342 self.class.read_inheritable_attribute('accept_key_auth_actions') || []
344 ActiveSupport::Deprecaction.warn "ApplicationController.accept_key_auth_actions is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
345 self.class.accept_rss_auth
346 end
347
348 def self.accept_rss_auth(*actions)
349 if actions.any?
350 write_inheritable_attribute('accept_rss_auth_actions', actions)
351 else
352 read_inheritable_attribute('accept_rss_auth_actions') || []
353 end
354 end
355
356 def accept_rss_auth?(action=action_name)
357 self.class.accept_rss_auth.include?(action.to_sym)
358 end
359
360 def self.accept_api_auth(*actions)
361 if actions.any?
362 write_inheritable_attribute('accept_api_auth_actions', actions)
363 else
364 read_inheritable_attribute('accept_api_auth_actions') || []
365 end
366 end
367
368 def accept_api_auth?(action=action_name)
369 self.class.accept_api_auth.include?(action.to_sym)
343 370 end
344 371
345 372 # Returns the number of objects that should be displayed
@@ -1,5 +1,5
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -18,7 +18,7
18 18 class BoardsController < ApplicationController
19 19 default_search_scope :messages
20 20 before_filter :find_project, :find_board_if_available, :authorize
21 accept_key_auth :index, :show
21 accept_rss_auth :index, :show
22 22
23 23 helper :messages
24 24 include MessagesHelper
@@ -1,4 +1,4
1 # redMine - project management software
1 # Redmine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
@@ -27,7 +27,8 class IssuesController < ApplicationController
27 27 before_filter :find_optional_project, :only => [:index]
28 28 before_filter :check_for_default_issue_status, :only => [:new, :create]
29 29 before_filter :build_new_issue_from_params, :only => [:new, :create]
30 accept_key_auth :index, :show, :create, :update, :destroy
30 accept_rss_auth :index, :show
31 accept_api_auth :index, :show, :create, :update, :destroy
31 32
32 33 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
33 34
@@ -20,7 +20,7 class JournalsController < ApplicationController
20 20 before_filter :find_issue, :only => [:new]
21 21 before_filter :find_optional_project, :only => [:index]
22 22 before_filter :authorize, :only => [:new, :edit, :diff]
23 accept_key_auth :index
23 accept_rss_auth :index
24 24 menu_item :issues
25 25
26 26 helper :issues
@@ -23,7 +23,8 class NewsController < ApplicationController
23 23 before_filter :find_project, :only => [:new, :create]
24 24 before_filter :authorize, :except => [:index]
25 25 before_filter :find_optional_project, :only => :index
26 accept_key_auth :index
26 accept_rss_auth :index
27 accept_api_auth :index
27 28
28 29 helper :watchers
29 30
@@ -24,7 +24,8 class ProjectsController < ApplicationController
24 24 before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
25 25 before_filter :authorize_global, :only => [:new, :create]
26 26 before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
27 accept_key_auth :index, :show, :create, :update, :destroy
27 accept_rss_auth :index
28 accept_api_auth :index, :show, :create, :update, :destroy
28 29
29 30 after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
30 31 if controller.request.post?
@@ -30,7 +30,7 class RepositoriesController < ApplicationController
30 30 before_filter :find_repository, :except => :edit
31 31 before_filter :find_project, :only => :edit
32 32 before_filter :authorize
33 accept_key_auth :revisions
33 accept_rss_auth :revisions
34 34
35 35 rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
36 36
@@ -1,5 +1,5
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
@@ -22,7 +22,8 class TimelogController < ApplicationController
22 22 before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
23 23 before_filter :authorize, :except => [:index]
24 24 before_filter :find_optional_project, :only => [:index]
25 accept_key_auth :index, :show, :create, :update, :destroy
25 accept_rss_auth :index
26 accept_api_auth :index, :show, :create, :update, :destroy
26 27
27 28 helper :sort
28 29 include SortHelper
@@ -20,7 +20,7 class UsersController < ApplicationController
20 20
21 21 before_filter :require_admin, :except => :show
22 22 before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership]
23 accept_key_auth :index, :show, :create, :update, :destroy
23 accept_api_auth :index, :show, :create, :update, :destroy
24 24
25 25 helper :sort
26 26 include SortHelper
General Comments 0
You need to be logged in to leave comments. Login now