mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
Add backwards compatible accessors for ldap_cn and ldap_access
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user