Commit 577f2ceb authored by James Lopez's avatar James Lopez

add EE keys service

parent 3971768a
module Keys
class CreateService < ::Keys::BaseService
prepend EE::Keys::CreateService
def execute
key = user.keys.create(params)
notification_service.new_key(key) if key.persisted?
......
module EE
module Keys
module CreateService
def initialize(user, params)
super(user, params)
@ip_address = params.delete(:ip_address)
end
def execute
super.tap do |key|
log_audit_event(key)
end
end
def log_audit_event(key)
::AuditEventService.new(@user,
@user,
action: :custom,
custom_message: 'Added SSH key',
ip_address: @ip_address)
.for_user(key.title).security_event
end
end
end
end
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