2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-31 23:18:50 +08:00
|
|
|
class Auth::AuthProvider
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
def initialize(params = {})
|
2019-05-07 10:22:37 +08:00
|
|
|
params.each { |key, value| public_send "#{key}=", value }
|
2018-07-31 23:18:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.auth_attributes
|
|
|
|
[:pretty_name, :title, :message, :frame_width, :frame_height, :authenticator,
|
|
|
|
:pretty_name_setting, :title_setting, :enabled_setting, :full_screen_login, :full_screen_login_setting,
|
2019-03-27 21:25:04 +08:00
|
|
|
:custom_url, :background_color, :icon]
|
2018-07-31 23:18:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
attr_accessor(*auth_attributes)
|
|
|
|
|
2018-12-01 00:58:18 +08:00
|
|
|
def enabled_setting=(val)
|
|
|
|
Discourse.deprecate("enabled_setting is deprecated. Please define authenticator.enabled? instead")
|
|
|
|
@enabled_setting = val
|
|
|
|
end
|
|
|
|
|
2018-12-03 23:02:31 +08:00
|
|
|
def background_color=(val)
|
|
|
|
Discourse.deprecate("background_color is no longer functional. Please use CSS instead")
|
|
|
|
end
|
2018-12-01 00:58:18 +08:00
|
|
|
|
2018-07-31 23:18:50 +08:00
|
|
|
def name
|
|
|
|
authenticator.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_connect
|
|
|
|
authenticator.can_connect_existing_user?
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_revoke
|
|
|
|
authenticator.can_revoke?
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|