Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-03-19 19:11:12 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-07 05:20:16 +0300
commitdb18993f652425b72c4b854e18a002e0ec44b196 (patch)
tree7466e5f6b154bd79e72c13a5021d92eb9d7e4a13 /app/controllers/projects/deploy_tokens_controller.rb
parentaade8b3652573db40e7b777c72caa922b0bc12ef (diff)
Create barebones for Deploytoken
Includes: - Model, factories, create service and controller actions - As usual, includes specs for everything - Builds UI (copy from PAT) - Add revoke action Closes #31591
Diffstat (limited to 'app/controllers/projects/deploy_tokens_controller.rb')
-rw-r--r--app/controllers/projects/deploy_tokens_controller.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/controllers/projects/deploy_tokens_controller.rb b/app/controllers/projects/deploy_tokens_controller.rb
new file mode 100644
index 00000000000..ecc6db50f2f
--- /dev/null
+++ b/app/controllers/projects/deploy_tokens_controller.rb
@@ -0,0 +1,34 @@
+class Projects::DeployTokensController < Projects::ApplicationController
+ before_action :authorize_admin_project!
+
+ def create
+ @token = DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute
+ token_params = {}
+
+ if @token.valid?
+ flash[:notice] = 'Your new project deploy token has been created.'
+ else
+ token_params = @token.attributes.slice("name", "scopes", "expires_at")
+ flash[:alert] = @token.errors.full_messages.join(', ').html_safe
+ end
+
+ redirect_to project_settings_repository_path(project, deploy_token: token_params)
+ end
+
+ def revoke
+ @token = @project.deploy_tokens.find(params[:id])
+ @token.revoke!
+
+ redirect_to project_settings_repository_path(project)
+ end
+
+ private
+
+ def deploy_token_params
+ params.require(:deploy_token).permit(:name, :expires_at, scopes: [])
+ end
+
+ def authorize_admin_project!
+ return render_404 unless can?(current_user, :admin_project, @project)
+ end
+end