"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20170529132120_ldap_multi_group_mapping.rb" (25 Mar 2021, 686 Bytes) of package /linux/www/zammad-4.0.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "20170529132120_ldap_multi_group_mapping.rb": 3.4.1_vs_3.5.0.

    1 class LdapMultiGroupMapping < ActiveRecord::Migration[4.2]
    2   def up
    3 
    4     # return if it's a new setup
    5     return if !Setting.exists?(name: 'system_init_done')
    6 
    7     # load existing LDAP config
    8     ldap_config = Setting.get('ldap_config')
    9 
   10     # exit early if no config is present
   11     return if ldap_config.blank?
   12     return if ldap_config['group_role_map'].blank?
   13 
   14     # loop over group role mapping and check
   15     # if we need to migrate to new array structure
   16     ldap_config['group_role_map'].each do |source, dest|
   17       next if dest.is_a?(Array)
   18 
   19       ldap_config['group_role_map'][source] = [dest]
   20     end
   21 
   22     # store updated
   23     Setting.set('ldap_config', ldap_config)
   24   end
   25 end