summaryrefslogtreecommitdiff
path: root/app/controllers/projects/settings/ci_cd_controller.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:08:00 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:08:00 +0000
commit1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (patch)
treeddb78a8a0d1350dc767f049a21e0f7d37edaa82c /app/controllers/projects/settings/ci_cd_controller.rb
parentb11f7057d067885619ee3e513751f180b2e8ad85 (diff)
downloadgitlab-ce-1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/settings/ci_cd_controller.rb')
-rw-r--r--app/controllers/projects/settings/ci_cd_controller.rb28
1 files changed, 23 insertions, 5 deletions
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index aac6ecb07e4..5feb3e019c2 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -7,6 +7,7 @@ module Projects
before_action :define_variables
before_action do
push_frontend_feature_flag(:new_variables_ui, @project)
+ push_frontend_feature_flag(:ajax_new_deploy_token, @project)
end
def show
@@ -47,13 +48,30 @@ module Projects
end
def create_deploy_token
- @new_deploy_token = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute
+ result = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute
+ @new_deploy_token = result[:deploy_token]
- if @new_deploy_token.persisted?
- flash.now[:notice] = s_('DeployTokens|Your new project deploy token has been created.')
+ 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 project 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
-
- render 'show'
end
private