2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-31 11:18:50 -04:00
|
|
|
class Auth::AuthProvider
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
def initialize(params = {})
|
2019-05-06 22:22:37 -04:00
|
|
|
params.each { |key, value| public_send "#{key}=", value }
|
2018-07-31 11:18:50 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.auth_attributes
|
2023-01-09 07:10:19 -05:00
|
|
|
%i[
|
2021-03-25 09:23:48 -04:00
|
|
|
authenticator
|
|
|
|
pretty_name
|
|
|
|
title
|
|
|
|
message
|
|
|
|
frame_width
|
|
|
|
frame_height
|
2018-07-31 11:18:50 -04:00
|
|
|
pretty_name_setting
|
|
|
|
title_setting
|
|
|
|
enabled_setting
|
|
|
|
full_screen_login
|
|
|
|
full_screen_login_setting
|
2019-03-27 09:25:04 -04:00
|
|
|
custom_url
|
|
|
|
background_color
|
|
|
|
icon
|
|
|
|
]
|
2018-07-31 11:18:50 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
attr_accessor(*auth_attributes)
|
|
|
|
|
2018-11-30 11:58:18 -05:00
|
|
|
def enabled_setting=(val)
|
2021-11-12 09:52:59 -05:00
|
|
|
Discourse.deprecate(
|
|
|
|
"(#{authenticator.name}) enabled_setting is deprecated. Please define authenticator.enabled? instead",
|
|
|
|
drop_from: "2.9.0",
|
|
|
|
)
|
2018-11-30 11:58:18 -05:00
|
|
|
@enabled_setting = val
|
|
|
|
end
|
|
|
|
|
2018-12-03 10:02:31 -05:00
|
|
|
def background_color=(val)
|
2021-11-12 09:52:59 -05:00
|
|
|
Discourse.deprecate(
|
|
|
|
"(#{authenticator.name}) background_color is no longer functional. Please use CSS instead",
|
|
|
|
drop_from: "2.9.0",
|
|
|
|
)
|
2019-10-08 07:10:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_screen_login=(val)
|
2021-11-12 09:52:59 -05:00
|
|
|
Discourse.deprecate(
|
|
|
|
"(#{authenticator.name}) full_screen_login is now forced. The full_screen_login parameter can be removed from the auth_provider.",
|
|
|
|
drop_from: "2.9.0",
|
|
|
|
)
|
2019-10-08 07:10:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_screen_login_setting=(val)
|
2021-11-12 09:52:59 -05:00
|
|
|
Discourse.deprecate(
|
|
|
|
"(#{authenticator.name}) full_screen_login is now forced. The full_screen_login_setting parameter can be removed from the auth_provider.",
|
|
|
|
drop_from: "2.9.0",
|
|
|
|
)
|
2018-12-03 10:02:31 -05:00
|
|
|
end
|
2018-11-30 11:58:18 -05:00
|
|
|
|
2021-03-25 09:23:48 -04:00
|
|
|
def message=(val)
|
2021-11-12 09:52:59 -05:00
|
|
|
Discourse.deprecate(
|
|
|
|
"(#{authenticator.name}) message is no longer used because all logins are full screen. It should be removed from the auth_provider",
|
|
|
|
drop_from: "2.9.0",
|
|
|
|
)
|
2021-03-25 09:23:48 -04:00
|
|
|
end
|
|
|
|
|
2018-07-31 11:18:50 -04:00
|
|
|
def name
|
|
|
|
authenticator.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_connect
|
|
|
|
authenticator.can_connect_existing_user?
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_revoke
|
|
|
|
authenticator.can_revoke?
|
|
|
|
end
|
|
|
|
end
|