diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/members/authorized_destroy_service.rb | 17 | ||||
-rw-r--r-- | app/services/members/destroy_service.rb | 7 |
2 files changed, 18 insertions, 6 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb new file mode 100644 index 00000000000..c23f90a6a10 --- /dev/null +++ b/app/services/members/authorized_destroy_service.rb @@ -0,0 +1,17 @@ +module Members + class AuthorizedDestroyService < BaseService + attr_accessor :member, :user + + def initialize(member, user = nil) + @member, @user = member, user + end + + def execute + member.destroy + + if member.request? && member.user != user + notification_service.decline_access_request(member) + end + end + end +end diff --git a/app/services/members/destroy_service.rb b/app/services/members/destroy_service.rb index 9e3f6af628d..9a2bf82ef51 100644 --- a/app/services/members/destroy_service.rb +++ b/app/services/members/destroy_service.rb @@ -11,12 +11,7 @@ module Members unless member && can?(current_user, "destroy_#{member.type.underscore}".to_sym, member) raise Gitlab::Access::AccessDeniedError end - - member.destroy - - if member.request? && member.user != current_user - notification_service.decline_access_request(member) - end + AuthorizedDestroyService.new(member, current_user).execute end end end |