Module: Decidim::OmniauthHelper

Included in:
ApplicationHelper
Defined in:
decidim-core/app/helpers/decidim/omniauth_helper.rb

Overview

Helper that provides methods to enable or disable omniauth buttons

Instance Method Summary collapse

Instance Method Details

#normalize_provider_name(provider) ⇒ Object

Public: normalize providers names to they can be used for buttons and icons.



8
9
10
11
12
# File 'decidim-core/app/helpers/decidim/omniauth_helper.rb', line 8

def normalize_provider_name(provider)
  return "x" if provider == :twitter

  provider.to_s.split("_").first
end

#oauth_icon(provider) ⇒ Object

Public: icon for omniauth buttons



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'decidim-core/app/helpers/decidim/omniauth_helper.rb', line 15

def oauth_icon(provider)
  info = current_organization.enabled_omniauth_providers[provider.to_sym]

  if info
    icon_path = info[:icon_path]
    return external_icon(icon_path) if icon_path

    name = info[:icon]
  end

  name ||= normalize_provider_name(provider)
  icon(name)
end

#provider_name(provider) ⇒ Object

Public: pretty print provider name



30
31
32
# File 'decidim-core/app/helpers/decidim/omniauth_helper.rb', line 30

def provider_name(provider)
  provider.to_s.gsub(/_|-/, " ").camelize
end