2022-07-25 08:09:06 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# rubocop: disable Gitlab/NamespacedClass
|
|
|
|
class ProjectAccessTokenEntity < API::Entities::PersonalAccessToken
|
|
|
|
include Gitlab::Routing
|
|
|
|
|
|
|
|
expose :revoke_path do |token, options|
|
|
|
|
project = options.fetch(:project)
|
|
|
|
|
|
|
|
next unless project
|
|
|
|
|
|
|
|
revoke_namespace_project_settings_access_token_path(
|
|
|
|
id: token,
|
|
|
|
namespace_id: project.namespace.path,
|
|
|
|
project_id: project.path)
|
|
|
|
end
|
|
|
|
|
2022-08-26 17:10:03 -04:00
|
|
|
expose :role do |token, options|
|
2022-07-25 08:09:06 -04:00
|
|
|
project = options.fetch(:project)
|
|
|
|
|
|
|
|
next unless project
|
|
|
|
next unless token.user
|
|
|
|
|
2022-08-26 17:10:03 -04:00
|
|
|
project.member(token.user)&.human_access
|
2022-07-25 08:09:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
# rubocop: enable Gitlab/NamespacedClass
|