debian-mirror-gitlab/app/controllers/groups/settings/repository_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.9 KiB
Ruby
Raw Normal View History

2020-04-25 10:58:03 +05:30
# frozen_string_literal: true
module Groups
module Settings
class RepositoryController < Groups::ApplicationController
2021-04-29 21:17:54 +05:30
layout 'group_settings'
2020-04-25 10:58:03 +05:30
skip_cross_project_access_check :show
2020-07-02 01:45:43 +05:30
before_action :authorize_create_deploy_token!
2020-04-25 10:58:03 +05:30
before_action :define_deploy_token_variables
before_action do
push_frontend_feature_flag(:ajax_new_deploy_token, @group)
end
2021-01-03 14:25:43 +05:30
feature_category :continuous_delivery
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-03 14:25:43 +05:30
2020-04-25 10:58:03 +05:30
def create_deploy_token
result = Groups::DeployTokens::CreateService.new(@group, current_user, deploy_token_params).execute
@new_deploy_token = result[:deploy_token]
if result[:status] == :success
respond_to do |format|
format.json do
# IMPORTANT: It's a security risk to expose the token value more than just once here!
json = API::Entities::DeployTokenWithToken.represent(@new_deploy_token).as_json
render json: json, status: result[:http_status]
end
format.html do
flash.now[:notice] = s_('DeployTokens|Your new group deploy token has been created.')
render :show
end
end
else
respond_to do |format|
format.json { render json: { message: result[:message] }, status: result[:http_status] }
format.html do
flash.now[:alert] = result[:message]
render :show
end
end
end
end
private
def define_deploy_token_variables
@deploy_tokens = @group.deploy_tokens.active
@new_deploy_token = DeployToken.new
end
def deploy_token_params
2020-05-24 23:13:21 +05:30
params.require(:deploy_token).permit(:name, :expires_at, :read_repository, :read_registry, :write_registry, :read_package_registry, :write_package_registry, :username)
2020-04-25 10:58:03 +05:30
end
end
end
end