summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Gilcher <felix.gilcher@asquera.de>2013-02-01 13:53:35 +0000
committerFelix Gilcher <felix.gilcher@asquera.de>2013-02-01 13:53:35 +0000
commitce6436b98a8a86356ee93e6eaf136d27d7f77b93 (patch)
tree1e648dfcc9c8a43bb9b4a122eb997b5074c8157e /lib
parentc72910a8bf782c10662dd4392e81ef6408f801ee (diff)
downloadgitlab-ce-ce6436b98a8a86356ee93e6eaf136d27d7f77b93.tar.gz
Don't crash when removing a user that's not project member
The attempt to revoke project access for a user that was not member of the project results in a 500 Internal Server error where it actually should result in a 200 OK since after the operation, the user is not member of the project. This turns the operation into an idempotent call that can be repeated with no ill effects. Updated the spec and changed the code accordingly. However, the result differs slightly, as we can't return the users project access level if the user was not member. I'm not aware if anybody relies on the result of this call. Fixes #2832
Diffstat (limited to 'lib')
-rw-r--r--lib/api/projects.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index cbef1ed3b50..5444ba6a205 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -132,7 +132,11 @@ module Gitlab
delete ":id/members/:user_id" do
authorize! :admin_project, user_project
users_project = user_project.users_projects.find_by_user_id params[:user_id]
- users_project.destroy
+ unless users_project.nil?
+ users_project.destroy
+ else
+ {:message => "Access revoked", :id => params[:user_id].to_i}
+ end
end
# Get project hooks