Commit 0643187c authored by James Lopez's avatar James Lopez

fix keys controller and remove old version

parent 577f2ceb
class Profiles::KeysController < Profiles::ApplicationController
prepend ::EE::Profiles::KeysController
skip_before_action :authenticate_user!, only: [:get_keys]
......@@ -16,7 +15,7 @@ class Profiles::KeysController < Profiles::ApplicationController
@key = Keys::CreateService.new(current_user, key_params).execute
if @key.persisted?
redirect_to_profile_key_path
redirect_to profile_key_path(@key)
else
@keys = current_user.keys.select(&:persisted?)
render :index
......@@ -52,15 +51,9 @@ class Profiles::KeysController < Profiles::ApplicationController
end
end
protected
def redirect_to_profile_key_path
redirect_to profile_key_path(@key)
end
private
def key_params
params.require(:key).permit(:title, :key)
params.require(:key).permit(:title, :key).merge(ip_address: request.remote_ip)
end
end
module EE
module Profiles
module KeysController
protected
def redirect_to_profile_key_path
raise NotImplementedError unless defined?(super)
log_audit_event
super
end
private
def log_audit_event
::AuditEventService.new(current_user,
current_user,
action: :custom,
custom_message: 'Added SSH key',
ip_address: request.remote_ip)
.for_user(@key.title).security_event
end
end
end
end
......@@ -4,7 +4,7 @@ module EE
def initialize(user, params)
super(user, params)
@ip_address = params.delete(:ip_address)
@ip_address = @params.delete(:ip_address)
end
def execute
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment