Skip to content

Commit

Permalink
Removed method introduced in 067b4f8
Browse files Browse the repository at this point in the history
There is already a method that does the same as the one I've introduced.
  • Loading branch information
romanblanco committed Mar 24, 2017
1 parent a2a3d82 commit d38bf8b
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1374,18 +1374,32 @@ def find_checked_items(prefix = nil)
end
end

# Test RBAC on every item checked
# Params:
# klass - class of accessed objects
def find_checked_items_with_rbac(klass, prefix = nil)
items = find_checked_items(prefix)
assert_rbac(klass, items)
items
end

# Test RBAC in case there is only one record, not checked by checkbox
def test_item_with_rbac(klass, id)
assert_rbac(klass, Array.wrap(id))
id
# Test RBAC in case there is only one record
# Params:
# klass - class of accessed object
# id - accessed object id
def find_by_id_filtered(klass, id, options = {})
raise _("Invalid input") unless is_integer?(id)
tested_object = klass.find(id)
raise _("Selected %{model_name} no longer exists") % {
:model_name => ui_lookup(:model => klass.to_s)} if tested_object.nil?
Rbac.filtered_object(tested_object, :user => current_user, :named_scope => options[:named_scope]) ||
raise(_("User '%{user_id}' is not authorized to access '%{model}' record id '%{record_id}'") %
{:user_id => current_userid,
:record_id => id,
:model => ui_lookup(:model => klass.to_s)})
end


# Common Saved Reports button handler routines
def process_saved_reports(saved_reports, task)
success_count = 0
Expand Down Expand Up @@ -2221,23 +2235,6 @@ def set_global_session_data
end
end

# Following 3 methods moved here to ensure they are loaded at the right time and will be available to all controllers
def find_by_id_filtered(db, id, options = {})
raise _("Invalid input") unless is_integer?(id)

db_obj = db.find_by(:id => from_cid(id))
if db_obj.nil?
msg = _("Selected %{model_name} no longer exists") % {:model_name => ui_lookup(:model => db.to_s)}
raise msg
end

Rbac.filtered_object(db_obj, :user => current_user, :named_scope => options[:named_scope]) ||
raise(_("User '%{user_id}' is not authorized to access '%{model}' record id '%{record_id}'") %
{:user_id => current_userid,
:record_id => id,
:model => ui_lookup(:model => db.to_s)})
end

def find_filtered(db)
user = current_user
mfilters = user ? user.get_managed_filters : []
Expand Down

0 comments on commit d38bf8b

Please sign in to comment.