Sha256: 854db0ecd25a7d0cbad60aed5c50c5e18f9b3eb695b8caa0edde5e764b315bde

Contents?: true

Size: 821 Bytes

Versions: 42

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Helper that provides methods to enable or disable omniauth buttons
  module OmniauthHelper
    # Public: normalize providers names to they can be used for buttons
    # and icons.
    def normalize_provider_name(provider)
      provider.to_s.split("_").first
    end

    # Public: icon for omniauth buttons
    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

    # Public: pretty print provider name
    def provider_name(provider)
      provider.to_s.gsub(/_|-/, " ").camelize
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.9 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.8 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.4 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.3 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.7 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.5 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.2 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.1 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.4 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.0 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.3 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.0.rc2 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.27.0.rc1 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.2 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.1 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.0 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.0.rc2 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.26.0.rc1 app/helpers/decidim/omniauth_helper.rb
decidim-core-0.25.2 app/helpers/decidim/omniauth_helper.rb