2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class MoveCasSettings < ActiveRecord::Migration[4.2]
|
2014-02-11 18:57:08 -05:00
|
|
|
def change
|
|
|
|
#As part of removing the build in CAS authentication we should
|
|
|
|
#convert the data over to be used by the plugin.
|
2014-05-06 09:41:59 -04:00
|
|
|
cas_hostname = SiteSetting.find_by(name: "cas_hostname")
|
|
|
|
cas_sso_hostname = SiteSetting.find_by(name: "cas_sso_hostname")
|
2017-07-27 21:20:09 -04:00
|
|
|
if cas_hostname && ! cas_sso_hostname
|
2014-02-11 18:57:08 -05:00
|
|
|
#convert the setting over for use by the plugin
|
|
|
|
cas_hostname.update_attribute(:name, 'cas_sso_hostname')
|
2017-07-27 21:20:09 -04:00
|
|
|
elsif cas_hostname && cas_sso_hostname
|
2014-02-11 18:57:08 -05:00
|
|
|
#copy the setting over for use by the plugin and delete the original setting
|
2017-07-27 21:20:09 -04:00
|
|
|
cas_sso_hostname.update_attribute(:value, cas_hostname.value)
|
2014-02-11 18:57:08 -05:00
|
|
|
cas_hostname.destroy
|
|
|
|
end
|
|
|
|
|
2014-05-06 09:41:59 -04:00
|
|
|
cas_domainname = SiteSetting.find_by(name: "cas_domainname")
|
|
|
|
cas_sso_email_domain = SiteSetting.find_by(name: "cas_sso_email_domain")
|
2017-07-27 21:20:09 -04:00
|
|
|
if cas_domainname && ! cas_sso_email_domain
|
2014-02-11 18:57:08 -05:00
|
|
|
#convert the setting over for use by the plugin
|
|
|
|
cas_domainname.update_attribute(:name, 'cas_sso_email_domain')
|
2017-07-27 21:20:09 -04:00
|
|
|
elsif cas_domainname && cas_sso_email_domain
|
2014-02-11 18:57:08 -05:00
|
|
|
#copy the setting over for use by the plugin and delete the original setting
|
2017-07-27 21:20:09 -04:00
|
|
|
cas_sso_email_domain.update_attribute(:value, cas_domainname.value)
|
2014-02-11 18:57:08 -05:00
|
|
|
cas_domainname.destroy
|
|
|
|
end
|
|
|
|
|
2014-05-06 09:41:59 -04:00
|
|
|
cas_logins = SiteSetting.find_by(name: "cas_logins")
|
2014-02-11 18:57:08 -05:00
|
|
|
if cas_logins
|
|
|
|
cas_logins.destroy
|
|
|
|
end
|
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
#remove the unused table
|
2014-02-11 18:57:08 -05:00
|
|
|
drop_table :cas_user_infos
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|