diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-09-07 22:11:20 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-09-07 22:11:20 +0000 |
commit | 3955dcb4cc4cf305282412988751155771bbc036 (patch) | |
tree | a58615fe3f10662977b2eff3b741841bd5518b4c /lib/api | |
parent | aad764871d8f9433b9ec1d3d4eb096aba870bfac (diff) | |
parent | 62bb6235c229a869052180f9709c4801116f02cc (diff) | |
download | gitlab-ce-3955dcb4cc4cf305282412988751155771bbc036.tar.gz |
Merge branch '30473-allow-creation-of-subgroups-with-gitlab_default_can_create_group-set-to-false' into 'master'
Make Members with Owner and Master roles always able to create subgroups
Closes #30473
See merge request !14046
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/groups.rb | 7 | ||||
-rw-r--r-- | lib/api/helpers.rb | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 31a918eda60..e817dcbbc4b 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -74,7 +74,12 @@ module API use :optional_params end post do - authorize! :create_group + parent_group = find_group!(params[:parent_id]) if params[:parent_id].present? + if parent_group + authorize! :create_subgroup, parent_group + else + authorize! :create_group + end group = ::Groups::CreateService.new(current_user, declared_params(include_missing: false)).execute diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 8b03df65ae4..00dbc2aee7a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -93,7 +93,7 @@ module API end def find_group(id) - if id =~ /^\d+$/ + if id.to_s =~ /^\d+$/ Group.find_by(id: id) else Group.find_by_full_path(id) |