You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class EmailDomainBlocksController < BaseController
  4. before_action :set_email_domain_block, only: [:show, :destroy]
  5. def index
  6. authorize :email_domain_block, :index?
  7. @email_domain_blocks = EmailDomainBlock.page(params[:page])
  8. end
  9. def new
  10. authorize :email_domain_block, :create?
  11. @email_domain_block = EmailDomainBlock.new
  12. end
  13. def create
  14. authorize :email_domain_block, :create?
  15. @email_domain_block = EmailDomainBlock.new(resource_params)
  16. if @email_domain_block.save
  17. log_action :create, @email_domain_block
  18. redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.created_msg')
  19. else
  20. render :new
  21. end
  22. end
  23. def destroy
  24. authorize @email_domain_block, :destroy?
  25. @email_domain_block.destroy!
  26. log_action :destroy, @email_domain_block
  27. redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.destroyed_msg')
  28. end
  29. private
  30. def set_email_domain_block
  31. @email_domain_block = EmailDomainBlock.find(params[:id])
  32. end
  33. def resource_params
  34. params.require(:email_domain_block).permit(:domain)
  35. end
  36. end
  37. end