Commit d677d17d authored by George Koltsov's avatar George Koltsov

Fix Group Import owner access level

parent de715ec8
---
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 ...@@ -51,7 +51,7 @@ module Gitlab
@importable.members.destroy_all # rubocop: disable DestroyAll @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 rescue => e
raise e, "Error adding importer user to #{@importable.class} members. #{e.message}" raise e, "Error adding importer user to #{@importable.class} members. #{e.message}"
end end
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,7 @@ module Gitlab
def user_already_member? def user_already_member?
member = @importable.members&.first member = @importable.members&.first
member&.user == @user && member.access_level >= relation_class::MAINTAINER member&.user == @user && member.access_level >= highest_access_level
end end
def add_team_member(member, existing_user = nil) def add_team_member(member, existing_user = nil)
...@@ -72,7 +72,7 @@ module Gitlab ...@@ -72,7 +72,7 @@ module Gitlab
parsed_hash(member).merge( parsed_hash(member).merge(
'source_id' => @importable.id, 'source_id' => @importable.id,
'importing' => true, 'importing' => true,
'access_level' => [member['access_level'], relation_class::MAINTAINER].min 'access_level' => [member['access_level'], highest_access_level].min
).except('user_id') ).except('user_id')
end end
...@@ -97,6 +97,12 @@ module Gitlab ...@@ -97,6 +97,12 @@ module Gitlab
GroupMember GroupMember
end end
end end
def highest_access_level
return relation_class::OWNER if relation_class == GroupMember
relation_class::MAINTAINER
end
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