diff options
Diffstat (limited to 'app/controllers/profiles/personal_access_tokens_controller.rb')
-rw-r--r-- | app/controllers/profiles/personal_access_tokens_controller.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb index 265fa505b2a..1a8908e8571 100644 --- a/app/controllers/profiles/personal_access_tokens_controller.rb +++ b/app/controllers/profiles/personal_access_tokens_controller.rb @@ -14,6 +14,13 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController name: params[:name], scopes: scopes ) + + respond_to do |format| + format.html + format.json do + render json: @active_personal_access_tokens + end + end end def create @@ -56,6 +63,28 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController def active_personal_access_tokens tokens = finder(state: 'active', sort: 'expires_at_asc').execute + + if Feature.enabled?('access_token_pagination') + tokens = tokens.page(page) + add_pagination_headers(tokens) + end + ::API::Entities::PersonalAccessTokenWithDetails.represent(tokens) end + + def add_pagination_headers(relation) + Gitlab::Pagination::OffsetHeaderBuilder.new( + request_context: self, + per_page: relation.limit_value, + page: relation.current_page, + next_page: relation.next_page, + prev_page: relation.prev_page, + total: relation.total_count, + params: params.permit(:page) + ).execute + end + + def page + (params[:page] || 1).to_i + end end |