Module: Decidim::OmniauthHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/decidim/omniauth_helper.rb
Overview
Helper that provides methods to enable or disable omniauth buttons
Instance Method Summary collapse
-
#any_social_provider_enabled? ⇒ Boolean
Public: returns true if any provider is enabled.
-
#normalize_provider_name(provider) ⇒ Object
Public: normalize providers names to they can be used for buttons and icons.
-
#oauth_icon(provider) ⇒ Object
Public: icon for omniauth buttons.
-
#social_provider_enabled?(provider) ⇒ Boolean
Public: returns true if the social provider is enabled.
Instance Method Details
#any_social_provider_enabled? ⇒ Boolean
Public: returns true if any provider is enabled
12 13 14 15 16 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 12 def User.omniauth_providers.any? do |provider| provider end end |
#normalize_provider_name(provider) ⇒ Object
Public: normalize providers names to they can be used for buttons and icons.
20 21 22 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 20 def normalize_provider_name(provider) provider.to_s.split("_").first end |
#oauth_icon(provider) ⇒ Object
Public: icon for omniauth buttons
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 25 def oauth_icon(provider) info = Rails.application.secrets.dig(:omniauth, 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 |
#social_provider_enabled?(provider) ⇒ Boolean
Public: returns true if the social provider is enabled
7 8 9 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 7 def (provider) Rails.application.secrets.dig(:omniauth, provider.to_sym, :enabled) end |