diff options
Diffstat (limited to 'actionmailbox/app/controllers/action_mailbox/base_controller.rb')
-rw-r--r-- | actionmailbox/app/controllers/action_mailbox/base_controller.rb | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/actionmailbox/app/controllers/action_mailbox/base_controller.rb b/actionmailbox/app/controllers/action_mailbox/base_controller.rb index d4169cc9bb..cc22ea803c 100644 --- a/actionmailbox/app/controllers/action_mailbox/base_controller.rb +++ b/actionmailbox/app/controllers/action_mailbox/base_controller.rb @@ -1,36 +1,38 @@ # frozen_string_literal: true -# The base class for all Active Mailbox ingress controllers. -class ActionMailbox::BaseController < ActionController::Base - skip_forgery_protection +module ActionMailbox + # The base class for all Active Mailbox ingress controllers. + class BaseController < ActionController::Base + skip_forgery_protection - before_action :ensure_configured + before_action :ensure_configured - def self.prepare - # Override in concrete controllers to run code on load. - end + def self.prepare + # Override in concrete controllers to run code on load. + end - private - def ensure_configured - unless ActionMailbox.ingress == ingress_name - head :not_found + private + def ensure_configured + unless ActionMailbox.ingress == ingress_name + head :not_found + end end - end - def ingress_name - self.class.name.remove(/\AActionMailbox::Ingresses::/, /::InboundEmailsController\z/).underscore.to_sym - end + def ingress_name + self.class.name.remove(/\AActionMailbox::Ingresses::/, /::InboundEmailsController\z/).underscore.to_sym + end - def authenticate_by_password - if password.present? - http_basic_authenticate_or_request_with name: "actionmailbox", password: password, realm: "Action Mailbox" - else - raise ArgumentError, "Missing required ingress credentials" + def authenticate_by_password + if password.present? + http_basic_authenticate_or_request_with name: "actionmailbox", password: password, realm: "Action Mailbox" + else + raise ArgumentError, "Missing required ingress credentials" + end end - end - def password - Rails.application.credentials.dig(:action_mailbox, :ingress_password) || ENV["RAILS_INBOUND_EMAIL_PASSWORD"] - end + def password + Rails.application.credentials.dig(:action_mailbox, :ingress_password) || ENV["RAILS_INBOUND_EMAIL_PASSWORD"] + end + end end |