2018-07-05 06:18:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-07-03 07:54:50 -04:00
|
|
|
class AuditEventService
|
|
|
|
def initialize(author, entity, details = {})
|
|
|
|
@author, @entity, @details = author, entity, details
|
|
|
|
end
|
|
|
|
|
|
|
|
def for_authentication
|
|
|
|
@details = {
|
|
|
|
with: @details[:with],
|
|
|
|
target_id: @author.id,
|
2016-07-06 09:26:59 -04:00
|
|
|
target_type: 'User',
|
2017-05-03 07:22:03 -04:00
|
|
|
target_details: @author.name
|
2015-07-03 07:54:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def security_event
|
|
|
|
SecurityEvent.create(
|
|
|
|
author_id: @author.id,
|
|
|
|
entity_id: @entity.id,
|
|
|
|
entity_type: @entity.class.name,
|
|
|
|
details: @details
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|