rosa-build/app/controllers/platforms/key_pairs_controller.rb

32 lines
844 B
Ruby
Raw Normal View History

class Platforms::KeyPairsController < Platforms::BaseController
2015-03-04 23:19:19 +00:00
before_action :authenticate_user!
2012-07-13 12:18:12 +01:00
2014-10-27 21:22:35 +00:00
def index
@key_pair = KeyPair.new
end
2012-07-13 12:18:12 +01:00
def create
@key_pair = KeyPair.new params[:key_pair]
2012-07-13 12:18:12 +01:00
@key_pair.user_id = current_user.id
authorize @key_pair
2012-07-30 20:07:49 +01:00
if @key_pair.save
2012-07-13 12:18:12 +01:00
flash[:notice] = t('flash.key_pairs.saved')
2014-10-27 21:22:35 +00:00
redirect_to platform_key_pairs_path(@key_pair.repository.platform) and return
2012-07-13 12:18:12 +01:00
else
flash[:error] = t('flash.key_pairs.save_error')
end
2014-10-27 21:22:35 +00:00
render :index
2012-07-13 12:18:12 +01:00
end
def destroy
authorize @key_pair = @platform.key_pairs.find(params[:id])
2012-07-30 20:07:49 +01:00
if @key_pair.destroy
2012-07-13 12:18:12 +01:00
flash[:notice] = t('flash.key_pairs.destroyed')
else
flash[:error] = t('flash.key_pairs.destroy_error')
end
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
2012-07-13 12:18:12 +01:00
end
end