From 8f76b76cf3ddf121f0578a2386b4bef1df6b5693 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 21 May 2014 19:40:59 -0400 Subject: [PATCH] FIX: new sites would get enable_google_logins true, should be false now --- config/site_settings.yml | 4 ++++ ...140521220115_google_openid_default_has_changed.rb | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config/site_settings.yml b/config/site_settings.yml index 9f7df9c150e..f99260cea35 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -113,9 +113,13 @@ users: client: true default: 8 block_common_passwords: true + + # The default value of enable_google_logins changed from true to false. + # See db/migrate/20140521220115_google_openid_default_has_changed.rb enable_google_logins: client: true default: false + enable_google_oauth2_logins: client: true default: true diff --git a/db/migrate/20140521220115_google_openid_default_has_changed.rb b/db/migrate/20140521220115_google_openid_default_has_changed.rb index 3ee8ac3c300..4d154073daa 100644 --- a/db/migrate/20140521220115_google_openid_default_has_changed.rb +++ b/db/migrate/20140521220115_google_openid_default_has_changed.rb @@ -1,9 +1,13 @@ class GoogleOpenidDefaultHasChanged < ActiveRecord::Migration def up - result = Category.exec_sql("SELECT count(*) FROM site_settings WHERE name = 'enable_google_logins'") - if result[0]['count'].to_i == 0 - # The old default was true, so add a row to keep it that way. - execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('enable_google_logins', 5, 't', now(), now())" + users_count_query = User.exec_sql("SELECT count(*) FROM users") + if users_count_query[0]['count'].to_i > 1 + # This is an existing site. + result = User.exec_sql("SELECT count(*) FROM site_settings WHERE name = 'enable_google_logins'") + if result[0]['count'].to_i == 0 + # The old default was true, so add a row to keep it that way. + execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('enable_google_logins', 5, 't', now(), now())" + end end end