diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb
index 589f4c2f6..59a1703bc 100644
--- a/app/models/admin_dashboard_data.rb
+++ b/app/models/admin_dashboard_data.rb
@@ -11,7 +11,7 @@ class AdminDashboardData
def as_json
@json ||= {
reports: REPORTS.map { |type| Report.find(type) },
- problems: [rails_env_check, host_names_check, gc_checks, sidekiq_check || clockwork_check, ram_check].compact,
+ problems: [rails_env_check, host_names_check, gc_checks, sidekiq_check || clockwork_check, ram_check, facebook_config_check, twitter_config_check, github_config_check].compact,
admins: User.admins.count,
moderators: User.moderators.count
}.merge(
@@ -43,4 +43,16 @@ class AdminDashboardData
def ram_check
I18n.t('dashboard.memory_warning') if MemInfo.new.mem_total and MemInfo.new.mem_total < 1_000_000
end
-end
+
+ def facebook_config_check
+ I18n.t('dashboard.facebook_config_warning') if SiteSetting.enable_facebook_logins and (!SiteSetting.facebook_app_id.present? or !SiteSetting.facebook_app_secret.present?)
+ end
+
+ def twitter_config_check
+ I18n.t('dashboard.twitter_config_warning') if SiteSetting.enable_twitter_logins and (!SiteSetting.twitter_consumer_key.present? or !SiteSetting.twitter_consumer_secret.present?)
+ end
+
+ def github_config_check
+ I18n.t('dashboard.github_config_warning') if SiteSetting.enable_github_logins and (!SiteSetting.github_client_id.present? or !SiteSetting.github_client_secret.present?)
+ end
+end
\ No newline at end of file
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 075f7b969..3be25c2f1 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -298,6 +298,9 @@ en:
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. Learn about clockwork here.'
sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. Learn about Sidekiq here.'
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'
+ facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.'
+ twitter_config_warning: 'The server is configured to allow signup and log in with Twitter (enable_twitter_logins), but the key and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.'
+ github_config_warning: 'The server is configured to allow signup and log in with GitHub (enable_github_logins), but the client id and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.'
site_settings:
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"
diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb
index 0fbfccaae..87e0e102d 100644
--- a/spec/models/admin_dashboard_data_spec.rb
+++ b/spec/models/admin_dashboard_data_spec.rb
@@ -121,4 +121,70 @@ describe AdminDashboardData do
end
end
+ describe 'auth_config_checks' do
+
+ shared_examples_for 'problem detection for login providers' do
+ context 'when disabled' do
+ it 'returns nil' do
+ SiteSetting.stubs(enable_setting).returns(false)
+ subject.should be_nil
+ end
+ end
+
+ context 'when enabled' do
+ before do
+ SiteSetting.stubs(enable_setting).returns(true)
+ end
+
+ it 'returns nil key and secret are set' do
+ SiteSetting.stubs(key).returns('12313213')
+ SiteSetting.stubs(secret).returns('12312313123')
+ subject.should be_nil
+ end
+
+ it 'returns a string when key is not set' do
+ SiteSetting.stubs(key).returns('')
+ SiteSetting.stubs(secret).returns('12312313123')
+ subject.should_not be_nil
+ end
+
+ it 'returns a string when secret is not set' do
+ SiteSetting.stubs(key).returns('123123')
+ SiteSetting.stubs(secret).returns('')
+ subject.should_not be_nil
+ end
+
+ it 'returns a string when key and secret are not set' do
+ SiteSetting.stubs(key).returns('')
+ SiteSetting.stubs(secret).returns('')
+ subject.should_not be_nil
+ end
+ end
+ end
+
+ describe 'facebook' do
+ subject { AdminDashboardData.new.facebook_config_check }
+ let(:enable_setting) { :enable_facebook_logins }
+ let(:key) { :facebook_app_id }
+ let(:secret) { :facebook_app_secret }
+ it_should_behave_like 'problem detection for login providers'
+ end
+
+ describe 'twitter' do
+ subject { AdminDashboardData.new.twitter_config_check }
+ let(:enable_setting) { :enable_twitter_logins }
+ let(:key) { :twitter_consumer_key }
+ let(:secret) { :twitter_consumer_secret }
+ it_should_behave_like 'problem detection for login providers'
+ end
+
+ describe 'github' do
+ subject { AdminDashboardData.new.github_config_check }
+ let(:enable_setting) { :enable_github_logins }
+ let(:key) { :github_client_id }
+ let(:secret) { :github_client_secret }
+ it_should_behave_like 'problem detection for login providers'
+ end
+ end
+
end
\ No newline at end of file