2015-09-11 14:41:01 +05:30
|
|
|
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-08-24 12:49:21 +05:30
|
|
|
target_type: 'User',
|
2015-09-11 14:41:01 +05:30
|
|
|
target_details: @author.name,
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def security_event
|
|
|
|
SecurityEvent.create(
|
|
|
|
author_id: @author.id,
|
|
|
|
entity_id: @entity.id,
|
|
|
|
entity_type: @entity.class.name,
|
|
|
|
details: @details
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|