Sha256: e252dc50f6444df0dff35cac2c1ed53b6d2dbe577f77ddd1995cf69fcf42ddcb

Contents?: true

Size: 776 Bytes

Versions: 4

Compression:

Stored size: 776 Bytes

Contents

module Maily
  class ApplicationController < Maily.base_controller.constantize
    before_action :maily_enabled?, :http_authorization

    layout 'maily/application'

    def maily_params
      _params = {}

      [:mailer, :email, :version, :part, :locale, :version].each do |key|
        _params[key] = params[key] if params[key].present?
      end

      _params
    end
    helper_method :maily_params

    private

    def maily_enabled?
      Maily.enabled || head(404, message: "Maily disabled")
    end

    def http_authorization
      if auth_hash = Maily.http_authorization
        authenticate_or_request_with_http_basic do |username, password|
          username == auth_hash[:username] && password == auth_hash[:password]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
maily-2.1.0 app/controllers/maily/application_controller.rb
maily-2.0.2 app/controllers/maily/application_controller.rb
maily-2.0.1 app/controllers/maily/application_controller.rb
maily-2.0.0 app/controllers/maily/application_controller.rb