deploy_tokens_controller.rb 668 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
class Projects::DeployTokensController < Projects::ApplicationController
  before_action :authorize_admin_project!

  def create
    @token = DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute

    if @token.valid?
      flash[:notice] = 'Your new project deploy token has been created.'
    end

Mayra Cabrera's avatar
Mayra Cabrera committed
11
    redirect_to project_settings_repository_path(project)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  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
end