FIX: Include auth_providers for anonymous users when login_required

This commit is contained in:
David Taylor 2018-08-07 09:20:09 +01:00
parent 9e63ebdf0f
commit aa9a9a5a72
2 changed files with 13 additions and 1 deletions

View File

@ -91,6 +91,9 @@ class Site
filters: Discourse.filters.map(&:to_s),
user_fields: UserField.all.map do |userfield|
UserFieldSerializer.new(userfield, root: false, scope: guardian)
end,
auth_providers: Discourse.enabled_auth_providers.map do |provider|
AuthProviderSerializer.new(provider, root: false, scope: guardian)
end
}.to_json
end

View File

@ -69,7 +69,16 @@ describe Site do
it "includes all enabled authentication providers" do
SiteSetting.enable_twitter_logins = true
SiteSetting.enable_facebook_logins = true
expect(Site.new(Guardian.new).auth_providers.map(&:name)).to contain_exactly('facebook', 'twitter')
data = JSON.parse(Site.json_for(Guardian.new))
expect(data["auth_providers"].map { |a| a["name"] }).to contain_exactly('facebook', 'twitter')
end
it "includes all enabled authentication providers for anon when login_required" do
SiteSetting.login_required = true
SiteSetting.enable_twitter_logins = true
SiteSetting.enable_facebook_logins = true
data = JSON.parse(Site.json_for(Guardian.new))
expect(data["auth_providers"].map { |a| a["name"] }).to contain_exactly('facebook', 'twitter')
end
end