Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-23 03:10:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-23 03:10:18 +0300
commit2994a84f0137ecf313e87bd3a79f433ab615f984 (patch)
tree082e6125a63b0e93667738637aa5e27359c85364 /lib/api/helpers.rb
parent6c68583a42998b0bb15971785f372197bfc55cd7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 6cb9d19a2ad..a59734d643d 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -211,18 +211,25 @@ module API
not_found!('Pipeline')
end
+ def find_organization!(id)
+ organization = Organizations::Organization.find_by_id(id)
+ check_organization_access(organization)
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
- def find_group(id)
+ def find_group(id, organization: nil)
+ collection = organization.present? ? Group.in_organization(organization) : Group.all
+
if id.to_s =~ INTEGER_ID_REGEX
- Group.find_by(id: id)
+ collection.find_by(id: id)
else
- Group.find_by_full_path(id)
+ collection.find_by_full_path(id)
end
end
# rubocop: enable CodeReuse/ActiveRecord
- def find_group!(id)
- group = find_group(id)
+ def find_group!(id, organization: nil)
+ group = find_group(id, organization: organization)
check_group_access(group)
end
@@ -835,6 +842,12 @@ module API
@sudo_identifier ||= params[SUDO_PARAM] || env[SUDO_HEADER]
end
+ def check_organization_access(organization)
+ return organization if can?(current_user, :read_organization, organization)
+
+ not_found!('Organization')
+ end
+
def secret_token
Gitlab::Shell.secret_token
end