Use a smarter way to transation to multi LDAP links push

parent 0d782652
...@@ -89,12 +89,4 @@ class Group < Namespace ...@@ -89,12 +89,4 @@ class Group < Namespace
def ldap_access def ldap_access
ldap_group_links.first.try(:group_access) ldap_group_links.first.try(:group_access)
end end
def old_ldap_cn
read_attribute(:ldap_cn)
end
def old_ldap_access
read_attribute(:ldap_access)
end
end end
class LdapGroupResetService class LdapGroupResetService
def execute(group, current_user) 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| group.members.includes(:user).each do |member|
user = member.user user = member.user
......
...@@ -4,9 +4,14 @@ class RenameLdapGroupToLdapGroupLink < ActiveRecord::Migration ...@@ -4,9 +4,14 @@ class RenameLdapGroupToLdapGroupLink < ActiveRecord::Migration
# NOTE: we use the old_ methods because the new methods are overloaded # NOTE: we use the old_ methods because the new methods are overloaded
# for backwards compatibility # for backwards compatibility
Group.where.not(ldap_cn: nil).each do |group| 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| # Make sure we use the database column, not the model methods
ldap_group_link.group_access = group.old_ldap_access 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 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