gitlab-org--gitlab-foss/app/controllers/projects/deploy_keys_controller.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

class Projects::DeployKeysController < Projects::ApplicationController
2012-01-17 17:46:13 -05:00
respond_to :html
# Authorize
before_action :authorize_admin_project!
2011-12-29 14:44:16 -05:00
2013-06-19 15:44:57 -04:00
layout "project_settings"
2011-12-29 14:44:16 -05:00
def index
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
2011-12-29 14:44:16 -05:00
end
def new
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
2011-12-29 14:44:16 -05:00
end
def create
2016-08-19 19:31:40 -04:00
@key = DeployKey.new(deploy_key_params.merge(user: current_user))
2013-05-06 08:10:55 -04:00
unless @key.valid? && @project.deploy_keys << @key
flash[:alert] = @key.errors.full_messages.join(',').html_safe
2012-01-17 18:00:40 -05:00
end
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
2011-12-29 14:44:16 -05:00
end
2013-05-06 08:10:55 -04:00
def enable
Projects::EnableDeployKeyService.new(@project, current_user, params).execute
2013-05-06 08:10:55 -04:00
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
2013-05-06 08:10:55 -04:00
end
def disable
@project.deploy_keys_projects.find_by(deploy_key_id: params[:id]).destroy
2013-05-06 08:10:55 -04:00
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
2013-05-06 08:10:55 -04:00
end
protected
def deploy_key_params
params.require(:deploy_key).permit(:key, :title, :can_push)
end
2011-12-29 14:44:16 -05:00
end