2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
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
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2017-05-30 06:26:45 +00:00
|
|
|
|
|
|
|
# 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
|