Extract Members::AuthorizedDestroyService from Members::DestroyService.
This commit is contained in:
parent
9adddebc6d
commit
b4b51441aa
|
@ -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
|
|
@ -10,12 +10,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
|
||||
|
|
Loading…
Reference in New Issue