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
2021-03-25 21:23:48 +08:00
[ :authenticator , :pretty_name , :title , :message , :frame_width , :frame_height ,
2018-07-31 23:18:50 +08:00
: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 )
2021-11-12 22:52:59 +08:00
Discourse . deprecate ( " ( #{ authenticator . name } ) enabled_setting is deprecated. Please define authenticator.enabled? instead " , drop_from : '2.9.0' )
2018-12-01 00:58:18 +08:00
@enabled_setting = val
end
2018-12-03 23:02:31 +08:00
def background_color = ( val )
2021-11-12 22:52:59 +08:00
Discourse . deprecate ( " ( #{ authenticator . name } ) background_color is no longer functional. Please use CSS instead " , drop_from : '2.9.0' )
2019-10-08 19:10:43 +08:00
end
def full_screen_login = ( val )
2021-11-12 22:52:59 +08: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 19:10:43 +08:00
end
def full_screen_login_setting = ( val )
2021-11-12 22:52:59 +08: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 23:02:31 +08:00
end
2018-12-01 00:58:18 +08:00
2021-03-25 21:23:48 +08:00
def message = ( val )
2021-11-12 22:52:59 +08: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 21:23:48 +08:00
end
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