@@ -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 | class ActivitiesController < ApplicationController |
|
18 | class ActivitiesController < ApplicationController | |
2 | menu_item :activity |
|
19 | menu_item :activity | |
3 | before_filter :find_optional_project |
|
20 | before_filter :find_optional_project | |
4 |
accept_ |
|
21 | accept_rss_auth :index | |
5 |
|
22 | |||
6 | def index |
|
23 | def index | |
7 | @days = Setting.activity_days_default.to_i |
|
24 | @days = Setting.activity_days_default.to_i |
@@ -71,11 +71,11 class ApplicationController < ActionController::Base | |||||
71 | user = User.try_to_autologin(cookies[:autologin]) |
|
71 | user = User.try_to_autologin(cookies[:autologin]) | |
72 | session[:user_id] = user.id if user |
|
72 | session[:user_id] = user.id if user | |
73 | user |
|
73 | user | |
74 |
elsif params[:format] == 'atom' && |
|
74 | elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? | |
75 | # RSS key authentication does not start a session |
|
75 | # RSS key authentication does not start a session | |
76 | User.find_by_rss_key(params[:key]) |
|
76 | User.find_by_rss_key(params[:key]) | |
77 |
elsif Setting.rest_api_enabled? && a |
|
77 | elsif Setting.rest_api_enabled? && accept_api_auth? | |
78 | if (key = api_key_from_request) && accept_key_auth_actions.include?(params[:action]) |
|
78 | if (key = api_key_from_request) | |
79 | # Use API key |
|
79 | # Use API key | |
80 | User.find_by_api_key(key) |
|
80 | User.find_by_api_key(key) | |
81 | else |
|
81 | else | |
@@ -333,13 +333,40 class ApplicationController < ActionController::Base | |||||
333 | render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml' |
|
333 | render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml' | |
334 | end |
|
334 | end | |
335 |
|
335 | |||
|
336 | # TODO: remove in Redmine 1.4 | |||
336 | def self.accept_key_auth(*actions) |
|
337 | def self.accept_key_auth(*actions) | |
337 | actions = actions.flatten.map(&:to_s) |
|
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." | |
338 | write_inheritable_attribute('accept_key_auth_actions', actions) |
|
339 | accept_rss_auth(*actions) | |
339 | end |
|
340 | end | |
340 |
|
341 | |||
|
342 | # TODO: remove in Redmine 1.4 | |||
341 | def accept_key_auth_actions |
|
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 | end |
|
370 | end | |
344 |
|
371 | |||
345 | # Returns the number of objects that should be displayed |
|
372 | # Returns the number of objects that should be displayed |
@@ -1,5 +1,5 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -18,7 +18,7 | |||||
18 | class BoardsController < ApplicationController |
|
18 | class BoardsController < ApplicationController | |
19 | default_search_scope :messages |
|
19 | default_search_scope :messages | |
20 | before_filter :find_project, :find_board_if_available, :authorize |
|
20 | before_filter :find_project, :find_board_if_available, :authorize | |
21 |
accept_ |
|
21 | accept_rss_auth :index, :show | |
22 |
|
22 | |||
23 | helper :messages |
|
23 | helper :messages | |
24 | include MessagesHelper |
|
24 | include MessagesHelper |
@@ -1,4 +1,4 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or |
@@ -27,7 +27,8 class IssuesController < ApplicationController | |||||
27 | before_filter :find_optional_project, :only => [:index] |
|
27 | before_filter :find_optional_project, :only => [:index] | |
28 | before_filter :check_for_default_issue_status, :only => [:new, :create] |
|
28 | before_filter :check_for_default_issue_status, :only => [:new, :create] | |
29 | before_filter :build_new_issue_from_params, :only => [:new, :create] |
|
29 | before_filter :build_new_issue_from_params, :only => [:new, :create] | |
30 |
accept_ |
|
30 | accept_rss_auth :index, :show | |
|
31 | accept_api_auth :index, :show, :create, :update, :destroy | |||
31 |
|
32 | |||
32 | rescue_from Query::StatementInvalid, :with => :query_statement_invalid |
|
33 | rescue_from Query::StatementInvalid, :with => :query_statement_invalid | |
33 |
|
34 |
@@ -20,7 +20,7 class JournalsController < ApplicationController | |||||
20 | before_filter :find_issue, :only => [:new] |
|
20 | before_filter :find_issue, :only => [:new] | |
21 | before_filter :find_optional_project, :only => [:index] |
|
21 | before_filter :find_optional_project, :only => [:index] | |
22 | before_filter :authorize, :only => [:new, :edit, :diff] |
|
22 | before_filter :authorize, :only => [:new, :edit, :diff] | |
23 |
accept_ |
|
23 | accept_rss_auth :index | |
24 | menu_item :issues |
|
24 | menu_item :issues | |
25 |
|
25 | |||
26 | helper :issues |
|
26 | helper :issues |
@@ -23,7 +23,8 class NewsController < ApplicationController | |||||
23 | before_filter :find_project, :only => [:new, :create] |
|
23 | before_filter :find_project, :only => [:new, :create] | |
24 | before_filter :authorize, :except => [:index] |
|
24 | before_filter :authorize, :except => [:index] | |
25 | before_filter :find_optional_project, :only => :index |
|
25 | before_filter :find_optional_project, :only => :index | |
26 |
accept_ |
|
26 | accept_rss_auth :index | |
|
27 | accept_api_auth :index | |||
27 |
|
28 | |||
28 | helper :watchers |
|
29 | helper :watchers | |
29 |
|
30 |
@@ -24,7 +24,8 class ProjectsController < ApplicationController | |||||
24 | before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] |
|
24 | before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] | |
25 | before_filter :authorize_global, :only => [:new, :create] |
|
25 | before_filter :authorize_global, :only => [:new, :create] | |
26 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
|
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 | after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| |
|
30 | after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| | |
30 | if controller.request.post? |
|
31 | if controller.request.post? |
@@ -30,7 +30,7 class RepositoriesController < ApplicationController | |||||
30 | before_filter :find_repository, :except => :edit |
|
30 | before_filter :find_repository, :except => :edit | |
31 | before_filter :find_project, :only => :edit |
|
31 | before_filter :find_project, :only => :edit | |
32 | before_filter :authorize |
|
32 | before_filter :authorize | |
33 |
accept_ |
|
33 | accept_rss_auth :revisions | |
34 |
|
34 | |||
35 | rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed |
|
35 | rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed | |
36 |
|
36 |
@@ -1,5 +1,5 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-201 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -22,7 +22,8 class TimelogController < ApplicationController | |||||
22 | before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy] |
|
22 | before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy] | |
23 | before_filter :authorize, :except => [:index] |
|
23 | before_filter :authorize, :except => [:index] | |
24 | before_filter :find_optional_project, :only => [:index] |
|
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 | helper :sort |
|
28 | helper :sort | |
28 | include SortHelper |
|
29 | include SortHelper |
@@ -20,7 +20,7 class UsersController < ApplicationController | |||||
20 |
|
20 | |||
21 | before_filter :require_admin, :except => :show |
|
21 | before_filter :require_admin, :except => :show | |
22 | before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership] |
|
22 | before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership] | |
23 |
accept_ |
|
23 | accept_api_auth :index, :show, :create, :update, :destroy | |
24 |
|
24 | |||
25 | helper :sort |
|
25 | helper :sort | |
26 | include SortHelper |
|
26 | include SortHelper |
General Comments 0
You need to be logged in to leave comments.
Login now