summaryrefslogtreecommitdiff
path: root/lib/api/resource_access_tokens.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /lib/api/resource_access_tokens.rb
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/api/resource_access_tokens.rb')
-rw-r--r--lib/api/resource_access_tokens.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/api/resource_access_tokens.rb b/lib/api/resource_access_tokens.rb
index 705e4778c83..f42acc6b2eb 100644
--- a/lib/api/resource_access_tokens.rb
+++ b/lib/api/resource_access_tokens.rb
@@ -21,9 +21,10 @@ module API
next unauthorized! unless current_user.can?(:read_resource_access_tokens, resource)
- tokens = PersonalAccessTokensFinder.new({ user: resource.bots, impersonation: false }).execute
+ tokens = PersonalAccessTokensFinder.new({ user: resource.bots, impersonation: false }).execute.preload_users
- present paginate(tokens), with: Entities::PersonalAccessToken
+ resource.project_members.load
+ present paginate(tokens), with: Entities::ResourceAccessToken, project: resource
end
desc 'Revoke a resource access token' do
@@ -57,6 +58,7 @@ module API
requires :id, type: String, desc: "The #{source_type} ID"
requires :name, type: String, desc: "Resource access token name"
requires :scopes, type: Array[String], desc: "The permissions of the token"
+ optional :access_level, type: Integer, desc: "The access level of the token in the project"
optional :expires_at, type: Date, desc: "The expiration date of the token"
end
post ':id/access_tokens' do
@@ -69,7 +71,7 @@ module API
).execute
if token_response.success?
- present token_response.payload[:access_token], with: Entities::PersonalAccessTokenWithToken
+ present token_response.payload[:access_token], with: Entities::ResourceAccessTokenWithToken, project: resource
else
bad_request!(token_response.message)
end