Add backwards compatible accessors for ldap_cn and ldap_access

parent 3ba7a3a5
......@@ -80,4 +80,21 @@ class Group < Namespace
def public_profile?
projects.public_only.any?
end
# NOTE: Backwards compatibility with old ldap situation
def ldap_cn
ldap_group_links.first.try(:cn)
end
def ldap_access
ldap_group_links.first.try(:group_access)
end
def old_ldap_cn
read_attribute(:ldap_cn)
end
def old_ldap_access
read_attribute(:ldap_access)
end
end
......@@ -7,12 +7,6 @@ class AddLdapGroupsTable < ActiveRecord::Migration
t.timestamps
end
Group.where.not(ldap_cn: nil).each do |group|
group.ldap_groups.where(cn: group.ldap_cn).first_or_create do |ldap_group|
ldap_group.group_access = group.ldap_access
end
end
end
def down
......
class RenameLdapGroupToLdapGroupLink < ActiveRecord::Migration
def change
def up
rename_table :ldap_groups, :ldap_group_links
# NOTE: we use the old_ methods because the new methods are overloaded
# for backwards compatibility
Group.where.not(ldap_cn: nil).each do |group|
group.ldap_group_links.where(cn: group.old_ldap_cn).first_or_create do |ldap_group_link|
ldap_group_link.group_access = group.old_ldap_access
end
end
end
def down
rename_table :ldap_group_links, :ldap_groups
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment