2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/app/serializers/auth_provider_serializer.rb
Chris Alberti 1f227a5eb4
DEV: Add capability to pass an icon setting into auth provider registration (#34584)
Add capability to pass an icon setting into auth provider registration to override the default icon with a site setting.

Matches the pattern we use for the auth provider title and pretty name. 

With this, the SAML plugin can be updated to have a site setting to override the default "user" icon.
2025-08-28 09:14:36 -05:00

31 lines
853 B
Ruby

# frozen_string_literal: true
class AuthProviderSerializer < ApplicationSerializer
attributes :can_connect,
:can_revoke,
:custom_url,
:frame_height,
:frame_width,
:icon_override,
:name,
:pretty_name_override,
:provider_url,
:title_override
# ensures that the "/custom" route doesn't trigger the magic custom_url helper in ActionDispatch
def custom_url
object.custom_url
end
def pretty_name_override
object.pretty_name_setting ? SiteSetting.get(object.pretty_name_setting) : object.pretty_name
end
def title_override
object.title_setting ? SiteSetting.get(object.title_setting) : object.title
end
def icon_override
object.icon_setting ? SiteSetting.get(object.icon_setting) : object.icon
end
end