diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-07-03 14:54:50 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-07-06 12:36:08 +0300 |
commit | 411829fdb5f24f97ce17e05f5fd018d47075b216 (patch) | |
tree | aa39d65d78e0aa719df07ab268522a5bc3cb371f /app/services/audit_event_service.rb | |
parent | 8ba83cbab86349c5fa5ce5034df6ffc8225f137c (diff) |
Audit log for user authentication
Diffstat (limited to 'app/services/audit_event_service.rb')
-rw-r--r-- | app/services/audit_event_service.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/services/audit_event_service.rb b/app/services/audit_event_service.rb new file mode 100644 index 00000000000..a7f090655e1 --- /dev/null +++ b/app/services/audit_event_service.rb @@ -0,0 +1,25 @@ +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, + target_type: "User", + 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 |