2017-09-08 08:28:34 +00:00
|
|
|
class LdapMultiGroupMapping < ActiveRecord::Migration[4.2]
|
2017-05-30 06:26:45 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
|
|
|
return if !Setting.find_by(name: 'system_init_done')
|
|
|
|
|
|
|
|
# load existing LDAP config
|
|
|
|
ldap_config = Setting.get('ldap_config')
|
|
|
|
|
|
|
|
# exit early if no config is present
|
|
|
|
return if ldap_config.blank?
|
|
|
|
return if ldap_config['group_role_map'].blank?
|
|
|
|
|
|
|
|
# loop over group role mapping and check
|
|
|
|
# if we need to migrate to new array structure
|
|
|
|
ldap_config['group_role_map'].each do |source, dest|
|
|
|
|
next if dest.is_a?(Array)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-05-30 06:26:45 +00:00
|
|
|
ldap_config['group_role_map'][source] = [dest]
|
|
|
|
end
|
|
|
|
|
|
|
|
# store updated
|
|
|
|
Setting.set('ldap_config', ldap_config)
|
|
|
|
end
|
|
|
|
end
|