Commit 2033337c authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'georgekoltsov/fix-group-members-owner-access-level' into 'master'

Fix Group Import members' owner access level

See merge request gitlab-org/gitlab!25595
parents 945c94a2 d677d17d
---
title: Fix an issue with Group Import members with Owner access level being imported with Maintainer access level. Owner access level is now preserved
merge_request: 25595
author:
type: fixed
......@@ -51,7 +51,7 @@ module Gitlab
@importable.members.destroy_all # rubocop: disable DestroyAll
relation_class.create!(user: @user, access_level: relation_class::MAINTAINER, source_id: @importable.id, importing: true)
relation_class.create!(user: @user, access_level: highest_access_level, source_id: @importable.id, importing: true)
rescue => e
raise e, "Error adding importer user to #{@importable.class} members. #{e.message}"
end
......@@ -59,7 +59,7 @@ module Gitlab
def user_already_member?
member = @importable.members&.first
member&.user == @user && member.access_level >= relation_class::MAINTAINER
member&.user == @user && member.access_level >= highest_access_level
end
def add_team_member(member, existing_user = nil)
......@@ -72,7 +72,7 @@ module Gitlab
parsed_hash(member).merge(
'source_id' => @importable.id,
'importing' => true,
'access_level' => [member['access_level'], relation_class::MAINTAINER].min
'access_level' => [member['access_level'], highest_access_level].min
).except('user_id')
end
......@@ -97,6 +97,12 @@ module Gitlab
GroupMember
end
end
def highest_access_level
return relation_class::OWNER if relation_class == GroupMember
relation_class::MAINTAINER
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