Author: tchemit Date: 2012-07-12 15:33:21 +0200 (Thu, 12 Jul 2012) New Revision: 264 Url: http://nuiton.org/repositories/revision/jredmine/264 Log: add more check method (to be continued) Modified: trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb Modified: trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb =================================================================== --- trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb 2012-07-12 13:31:01 UTC (rev 263) +++ trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb 2012-07-12 13:33:21 UTC (rev 264) @@ -25,8 +25,12 @@ class JredmineController < ActionController::Base # post request - before_filter :check_post, :only => [:add_version, :update_version, :next_version, :add_news, :add_attachment, :add_version_attachment, :add_issue_time, :update_issue_time] - + #before_filter :check_post, :only => [:add_version, :update_version, :next_version, :add_news, :add_attachment, :add_version_attachment, :add_issue_time, :update_issue_time] + before_filter :check_post, :only => [:add_version, :add_news, :add_attachment, :add_version_attachment, :add_issue_time] + + # put request + before_filter :check_post, :only => [:update_version, :next_version, :update_issue_time] + # find user (after login) before_filter :find_user, :only => [:get_user_projects, :add_version, :update_version, :next_version, :add_news, :add_attachment, :add_version_attachment, :add_issue_time, :update_issue_time] @@ -430,6 +434,20 @@ end end + # Checks that action is using put method + def check_put + if !request.put? + render_status 405, "PUT method required for action #{params[:action]}" + end + end + + # Checks that action is using delete method + def check_delete + if !request.delete? + render_status 405, "DELETE method required for action #{params[:action]}" + end + end + # Checks that request has a version[name] attribute def check_version_definition(version = params[:version]) if version.nil?