Use a smarter way to transation to multi LDAP links push

parent 0d782652
......@@ -89,12 +89,4 @@ class Group < Namespace
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
class LdapGroupResetService
def execute(group, current_user)
# Only for ldap connected users
# reset last_credential_check_at
# set Gitlab::Access::Guest
group.members.includes(:user).each do |member|
user = member.user
......
......@@ -4,9 +4,14 @@ class RenameLdapGroupToLdapGroupLink < ActiveRecord::Migration
# 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
# Make sure we use the database column, not the model methods
ldap_cn = group.read_attribute(:ldap_cn)
ldap_access = group.read_attribute(:ldap_access)
group.ldap_group_links.where(cn: ldap_cn).first_or_create do |ldap_group_link|
ldap_group_link.group_access = ldap_access
end
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