Module: Decidim::TrustedIds::System::OrganizationFormOverride::EncryptedOmniauthSettingsOverride

Defined in:
app/forms/concerns/decidim/trusted_ids/system/organization_form_override.rb

Overview

Prepended into the form class so that super() correctly resolves to the core's encrypted_omniauth_settings. When icon_path is blank, sets the default path via the jsonb sub-attribute setter BEFORE calling super, so the core picks it up and encrypts it correctly. Empty string would be truthy in omniauth_settings and cause oauth_icon → external_icon("") to crash.

Instance Method Summary collapse

Instance Method Details

#encrypted_omniauth_settingsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/forms/concerns/decidim/trusted_ids/system/organization_form_override.rb', line 16

def encrypted_omniauth_settings
  provider = Decidim::TrustedIds.omniauth_provider
  icon_attr = :"omniauth_settings_#{provider}_icon_path"
  enabled_attr = :"omniauth_settings_#{provider}_enabled"

  # Only normalize blank icon_path when the provider is being enabled.
  # If not enabled, we leave all settings blank so the core can return nil
  # (preserving ENV-var-based configuration).
  if public_send(enabled_attr) && public_send(icon_attr).blank?
    default = Decidim::TrustedIds.omniauth[:icon_path].presence ||
              "media/images/#{provider.downcase}-icon.png"
    public_send(:"#{icon_attr}=", default)
  end

  super
end