diff options
Diffstat (limited to 'app/services/members')
-rw-r--r-- | app/services/members/authorized_destroy_service.rb | 2 | ||||
-rw-r--r-- | app/services/members/destroy_service.rb | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb index ca9db59cac7..b7a244c2029 100644 --- a/app/services/members/authorized_destroy_service.rb +++ b/app/services/members/authorized_destroy_service.rb @@ -14,6 +14,8 @@ module Members if member.request? && member.user != user notification_service.decline_access_request(member) end + + member end end end diff --git a/app/services/members/destroy_service.rb b/app/services/members/destroy_service.rb index b3d79d577bd..ee072065523 100644 --- a/app/services/members/destroy_service.rb +++ b/app/services/members/destroy_service.rb @@ -15,7 +15,7 @@ module Members def execute(scope = :members) raise "scope :#{scope} is not allowed!" unless ALLOWED_SCOPES.include?(scope) - member = find_member(scope) + member = find_member!(scope) raise Gitlab::Access::AccessDeniedError if cannot_destroy_member?(member) @@ -24,13 +24,14 @@ module Members private - def find_member(scope) + def find_member!(scope) + condition = params[:user_id] ? { user_id: params[:user_id] } : { id: params[:id] } case scope when :all - source.members.find_by(user_id: params[:user_id]) || - source.requesters.find_by!(user_id: params[:user_id]) + source.members.find_by(condition) || + source.requesters.find_by!(condition) else - source.public_send(scope).find_by!(user_id: params[:user_id]) + source.public_send(scope).find_by!(condition) end end |