Skip to content

Commit

Permalink
Merge pull request #963 from PanSpagetka/fix-rbac-for-floating-ips
Browse files Browse the repository at this point in the history
Fix RBAC for floating ips
  • Loading branch information
martinpovolny authored Apr 7, 2017
2 parents af79589 + 300518b commit 2dad101
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions app/controllers/floating_ip_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,17 @@ def create_finished

def delete_floating_ips
assert_privileges("floating_ip_delete")

floating_ips = if @lastaction == "show_list" || (@lastaction == "show" && @layout != "floating_ip")
find_checked_items
find_checked_records_with_rbac(FloatingIp)
else
[params[:id]]
[find_record_with_rbac(FloatingIp, params[:id])]
end

if floating_ips.empty?
add_flash(_("No Floating IPs were selected for deletion."), :error)
end

floating_ips_to_delete = []
floating_ips.each do |s|
floating_ip = FloatingIp.find(s)
if floating_ip.nil?
add_flash(_("Floating IP no longer exists."), :error)
else
floating_ips_to_delete.push(floating_ip)
end
end
process_floating_ips(floating_ips_to_delete, "destroy") unless floating_ips_to_delete.empty?
process_floating_ips(floating_ips, "destroy") unless floating_ips.empty?

# refresh the list if applicable
if @lastaction == "show_list"
Expand Down

0 comments on commit 2dad101

Please sign in to comment.