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