Commit b68e1123 authored by Marin Jankovski's avatar Marin Jankovski

Move event creation to service.

parent e3d96fc2
......@@ -25,12 +25,7 @@ class Groups::GroupMembersController < ApplicationController
target_type: "User",
target_details: @member.user.name,
}
SecurityEvent.create(
author_id: current_user.id,
entity_id: @group.id,
entity_type: "Group",
details: details
)
AuditEventService.new(current_user, @group, details).security_event
end
end
......
......@@ -39,12 +39,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
target_type: "User",
target_details: @user_project_relation.user.name,
}
SecurityEvent.create(
author_id: current_user.id,
entity_id: @project.id,
entity_type: "Project",
details: details
)
AuditEventService.new(current_user, @project, details).security_event
end
unless @user_project_relation.valid?
......
class AuditEventService
def initialize(author, entity, details = {})
@author, @entity, @details = author, entity, details
end
def security_event
SecurityEvent.create(
author_id: @author.id,
entity_id: @entity.id,
entity_type: @entity.class.name,
details: @details
)
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