2013-03-01 11:33:02 +00:00
|
|
|
class Users::SshKeysController < Users::BaseController
|
2015-03-04 23:19:19 +00:00
|
|
|
before_action :set_current_user
|
2015-04-06 23:54:16 +01:00
|
|
|
before_action -> { authorize current_user, :update? }
|
2015-04-23 11:28:16 +01:00
|
|
|
skip_before_action :find_user
|
2013-03-01 11:33:02 +00:00
|
|
|
|
|
|
|
def index
|
2014-11-06 22:00:23 +00:00
|
|
|
@ssh_key = SshKey.new
|
2013-03-01 11:33:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-05-26 22:48:22 +01:00
|
|
|
@ssh_key = current_user.ssh_keys.new ssh_key_params
|
2013-03-01 11:33:02 +00:00
|
|
|
|
|
|
|
if @ssh_key.save
|
|
|
|
flash[:notice] = t 'flash.ssh_keys.saved'
|
|
|
|
else
|
|
|
|
flash[:error] = t 'flash.ssh_keys.save_error'
|
2015-04-23 09:04:15 +01:00
|
|
|
flash[:warning] = @ssh_key.errors.full_messages.join('. ') unless @ssh_key.errors.blank?
|
2013-03-01 11:33:02 +00:00
|
|
|
end
|
2015-04-23 09:04:15 +01:00
|
|
|
redirect_to ssh_keys_path
|
2013-03-01 11:33:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@ssh_key = current_user.ssh_keys.find params[:id]
|
|
|
|
if @ssh_key.destroy
|
|
|
|
flash[:notice] = t 'flash.ssh_keys.destroyed'
|
|
|
|
else
|
|
|
|
flash[:error] = t 'flash.ssh_keys.destroy_error'
|
|
|
|
end
|
|
|
|
redirect_to ssh_keys_path
|
|
|
|
end
|
2014-11-13 00:23:01 +00:00
|
|
|
|
2015-05-26 22:48:22 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def ssh_key_params
|
|
|
|
subject_params(SshKey)
|
|
|
|
end
|
|
|
|
|
2015-04-06 23:54:16 +01:00
|
|
|
end
|