Class: Groovestack::Auth::Engine

Inherits:
Rails::Engine
  • Object
show all
Includes:
Base::CoreRailtie
Defined in:
lib/groovestack/auth/engine.rb

Instance Method Summary collapse

Instance Method Details

#dx_validationsObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/groovestack/auth/engine.rb', line 11

def dx_validations
  [
    {
      eval: proc {
        raise if ::Groovestack::Auth.enabled_providers_sans_configuration.present?
      },
      message: missing_configuration_msg
    }
  ]
end

#missing_configuration_msgObject



28
29
30
31
32
# File 'lib/groovestack/auth/engine.rb', line 28

def missing_configuration_msg
  msg = "\n\tWarning: enabled providers are missing required credentials:\n\t\t"
  msg += providers_missing_configuration.join("\n\t\t")
  "#{msg}\n\tAdd them to your credentials file or disable the providers by adding them to Groovestack::Auth.disabled_providers." # rubocop:disable Layout/LineLength
end

#module_descriptionObject



34
35
36
37
38
39
40
# File 'lib/groovestack/auth/engine.rb', line 34

def module_description
  avail = ::Groovestack::Auth.available_providers.map(&:k).map(&:to_s).map(&:titleize)
  descr = "\n\tAvailable auth providers: #{avail.join(', ')}"
  enabled = ::Groovestack::Auth.enabled_providers.map(&:k).map(&:to_s).map(&:titleize)
  descr += "\n\tEnabled auth providers: #{enabled.join(', ')}"
  descr
end

#providers_missing_configurationObject



22
23
24
25
26
# File 'lib/groovestack/auth/engine.rb', line 22

def providers_missing_configuration
  ::Groovestack::Auth.enabled_providers_sans_configuration.map do |h|
    "#{h.provider.to_s.titleize} - #{h.required_credentials.join(', ')}"
  end
end