Module: Panda::Core::SessionsHelper

Defined in:
app/helpers/panda/core/sessions_helper.rb

Constant Summary collapse

PROVIDER_ICON_MAP =

Map OAuth provider names to their FontAwesome icon names

{
  google_oauth2: "google",
  microsoft_graph: "microsoft",
  github: "github"
}.freeze
PROVIDER_NON_BRAND_ICONS =

Map of providers that don’t use fa-brands (use fa-solid instead)

{
  developer: "code"
}.freeze
PROVIDER_NAME_MAP =

Map OAuth provider names to their display names

{
  google_oauth2: "Google",
  microsoft_graph: "Microsoft",
  github: "GitHub",
  developer: "Developer"
}.freeze

Instance Method Summary collapse

Instance Method Details

#oauth_provider_icon(provider) ⇒ Object

Returns the FontAwesome icon name for a given provider Checks provider config first, then falls back to the mapping, then uses the provider name as-is



28
29
30
31
# File 'app/helpers/panda/core/sessions_helper.rb', line 28

def oauth_provider_icon(provider)
  provider_config = Panda::Core.config.authentication_providers[provider]
  provider_config&.dig(:icon) || PROVIDER_ICON_MAP[provider.to_sym] || PROVIDER_NON_BRAND_ICONS[provider.to_sym] || provider.to_s
end

#oauth_provider_name(provider, provider_config = nil) ⇒ Object

Returns the display name for a given provider Checks provider config first, then falls back to the mapping, then humanizes the provider name



40
41
42
43
# File 'app/helpers/panda/core/sessions_helper.rb', line 40

def oauth_provider_name(provider, provider_config = nil)
  provider_config ||= Panda::Core.config.authentication_providers[provider]
  provider_config&.dig(:name) || PROVIDER_NAME_MAP[provider.to_sym] || provider.to_s.humanize
end

#oauth_provider_non_brand?(provider) ⇒ Boolean

Returns true if the provider uses a non-brand icon (fa-solid, fa-regular, etc.)

Returns:

  • (Boolean)


34
35
36
# File 'app/helpers/panda/core/sessions_helper.rb', line 34

def oauth_provider_non_brand?(provider)
  PROVIDER_NON_BRAND_ICONS.key?(provider.to_sym)
end