mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: Serve auth provider information in the site serializer.
At the moment core providers are hard-coded in Javascript, and plugin providers get added to the JS payload at compile time. This refactor means that we only ship enabled providers to the client.
This commit is contained in:
28
lib/auth/auth_provider.rb
Normal file
28
lib/auth/auth_provider.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class Auth::AuthProvider
|
||||
include ActiveModel::Serialization
|
||||
|
||||
def initialize(params = {})
|
||||
params.each { |key, value| send "#{key}=", value }
|
||||
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,
|
||||
:custom_url]
|
||||
end
|
||||
|
||||
attr_accessor(*auth_attributes)
|
||||
|
||||
def name
|
||||
authenticator.name
|
||||
end
|
||||
|
||||
def can_connect
|
||||
authenticator.can_connect_existing_user?
|
||||
end
|
||||
|
||||
def can_revoke
|
||||
authenticator.can_revoke?
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user