2016-06-17 08:06:55 -04:00
|
|
|
module Members
|
|
|
|
class DestroyService < BaseService
|
|
|
|
attr_accessor :member, :current_user
|
|
|
|
|
|
|
|
def initialize(member, user)
|
|
|
|
@member, @current_user = member, user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-06-17 12:59:33 -04:00
|
|
|
unless member && can?(current_user, "destroy_#{member.type.underscore}".to_sym, member)
|
|
|
|
raise Gitlab::Access::AccessDeniedError
|
2016-06-17 08:06:55 -04:00
|
|
|
end
|
|
|
|
|
2016-06-17 12:59:33 -04:00
|
|
|
member.destroy
|
2016-06-17 08:06:55 -04:00
|
|
|
|
2016-06-17 12:59:33 -04:00
|
|
|
if member.request? && member.user != current_user
|
|
|
|
notification_service.decline_access_request(member)
|
|
|
|
end
|
2016-06-17 08:06:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|