diff options
author | Stan Hu <stanhu@gmail.com> | 2019-04-30 21:39:15 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-04-30 23:31:51 +0300 |
commit | 32ddc3fed616b9eebdd7b5553d4aa08c0572ff1d (patch) | |
tree | 97b7858c5d98135b836576caf1fa030c4ec772b6 /app/models/member.rb | |
parent | 9f592604032dd4a4d685fa359865ed9786f3e058 (diff) |
Allow a member to have an access level equal to parent group
Suppose you have this configuration:
1. Subgroup `hello/world`
2. Subgroup `hello/mergers`.
3. Project `hello/world/my-project` has invited group `hello/world` to
access protected branches.
4. The rule allows the group to merge but no one can push.
5. User `newuser` has Owner access to the parent group `hello`.
Previously, there was no way for the user `newuser` to be added to the
`hello/mergers` group since the validation only allowed a user to be
added at a higher access level.
Since membership in a subgroup confers certain access rights, such as
being able to merge or push code to protected branches, we have to
loosen the validation and allow someone to be added at an equal level
granted by the parent group.
Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/11323
Diffstat (limited to 'app/models/member.rb')
-rw-r--r-- | app/models/member.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/member.rb b/app/models/member.rb index 8a06bff51b5..83b4f5b29c4 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -446,10 +446,10 @@ class Member < ApplicationRecord end def higher_access_level_than_group - if highest_group_member && highest_group_member.access_level >= access_level + if highest_group_member && highest_group_member.access_level > access_level error_parameters = { access: highest_group_member.human_access, group_name: highest_group_member.group.name } - errors.add(:access_level, s_("should be higher than %{access} inherited membership from group %{group_name}") % error_parameters) + errors.add(:access_level, s_("should be greater than or equal to %{access} inherited membership from group %{group_name}") % error_parameters) end end end |