2013-09-02 16:03:31 +01:00
|
|
|
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
|
|
|
load_and_authorize_resource :platform
|
2014-01-21 04:51:49 +00:00
|
|
|
load_and_authorize_resource only: [:create, :destroy]
|
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.user_id = current_user.id
|
|
|
|
|
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
|
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
|
|
|
|
|
2012-07-31 13:50:53 +01:00
|
|
|
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
|
2012-07-13 12:18:12 +01:00
|
|
|
end
|
|
|
|
end
|