2013-09-02 16:03:31 +01:00
|
|
|
class Platforms::KeyPairsController < Platforms::BaseController
|
2012-07-13 12:18:12 +01:00
|
|
|
before_filter :authenticate_user!
|
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
load_and_authorize_resource :platform, only: [:index]
|
|
|
|
load_and_authorize_resource only: [:create, :destroy]
|
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')
|
|
|
|
else
|
|
|
|
flash[:error] = t('flash.key_pairs.save_error')
|
2012-07-13 15:16:56 +01:00
|
|
|
flash[:warning] = @key_pair.errors.full_messages.join('. ') unless @key_pair.errors.blank?
|
2012-07-13 12:18:12 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|