Defect #40121 ยป fix_invalid_cross_origin_request_exception.patch
| app/controllers/application_controller.rb | ||
|---|---|---|
|
rescue_from ::Unauthorized, :with => :deny_access
|
||
|
rescue_from ::ActionView::MissingTemplate, :with => :missing_template
|
||
|
rescue_from ActionController::InvalidCrossOriginRequest, with: :render_unauthorized
|
||
|
include Redmine::Search::Controller
|
||
|
include Redmine::MenuManager::MenuController
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def render_unauthorized
|
||
|
@project = nil
|
||
|
render_error({:message => :notice_not_authorized, :status => 403})
|
||
|
return false
|
||
|
end
|
||
|
def render_403(options={})
|
||
|
@project = nil
|
||
|
render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
|
||
| test/functional/projects_controller_test.rb | ||
|---|---|---|
|
assert_equal 'text/javascript', response.media_type
|
||
|
end
|
||
|
def test_requesting_protected_javascript_should_rescue_invalid_cross_origin_request
|
||
|
assert_nothing_raised do
|
||
|
get(
|
||
|
:autocomplete,
|
||
|
:params => {
|
||
|
:format => 'js'
|
||
|
}
|
||
|
)
|
||
|
assert_response :forbidden
|
||
|
end
|
||
|
end
|
||
|
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||
|
@request.session[:user_id] = 3
|
||
|
get :index
|
||