Class: Admin::SecurityController

Inherits:
ApplicationController
  • Object
show all
Includes:
AdminPagination, AuditLoggable
Defined in:
lib/generators/ruby_cms/templates/controllers/admin/security_controller.rb

Constant Summary

Constants included from AdminPagination

AdminPagination::DEFAULT_MAX_PER_PAGE, AdminPagination::DEFAULT_MIN_PER_PAGE

Instance Method Summary collapse

Methods included from AdminPagination

#paginate_collection, #set_pagination_vars

Instance Method Details

#create_ip_blocklist_entryObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/ruby_cms/templates/controllers/admin/security_controller.rb', line 19

def create_ip_blocklist_entry
  @ip_blocklist_entry = IpBlocklist.new(ip_blocklist_params)

  if @ip_blocklist_entry.save
    audit!(:ip_blocklisted, target: "IpBlocklist:#{@ip_blocklist_entry.ip_address}", summary: "Blocklisted IP #{@ip_blocklist_entry.ip_address}", meta: { ip: @ip_blocklist_entry.ip_address, note: @ip_blocklist_entry.note })
    handle_blocklist_success("IP-adres toegevoegd aan de blocklist.")
  else
    handle_blocklist_failure
  end
end

#destroy_ip_blocklist_entryObject



30
31
32
33
34
35
36
# File 'lib/generators/ruby_cms/templates/controllers/admin/security_controller.rb', line 30

def destroy_ip_blocklist_entry
  entry = IpBlocklist.find(params[:id])
  ip = entry.ip_address
  entry.destroy
  audit!(:ip_blocklist_removed, target: "IpBlocklist:#{ip}", summary: "Removed IP #{ip} from blocklist", meta: { ip: })
  handle_blocklist_success("IP-adres verwijderd van de blocklist.")
end

#indexObject



11
12
13
14
15
16
17
# File 'lib/generators/ruby_cms/templates/controllers/admin/security_controller.rb', line 11

def index
  load_dashboard_stats
  load_security_events
  load_ip_blocklist

  render_ip_blocklist_frame if ip_blocklist_frame?
end