diff options
author | Rémy Coutable <remy@rymai.me> | 2018-07-30 21:46:22 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-07-30 21:46:22 +0300 |
commit | 016dadc860251ade20860c2ca533a43dff789018 (patch) | |
tree | 11d9b2065cf09f25ba52f27812d560560997c58e /lib | |
parent | 0a40035c0762be80330a0155dc790d3fde90da68 (diff) | |
parent | 5bab78950d652ce15d87772ae2857f370fd926a4 (diff) |
Merge branch '32821-better-error-message-add-invalid-user-to-project' into 'master'
Resolve "Improve Error Message When Adding Invalid User to Project via API"
Closes #32821
See merge request gitlab-org/gitlab-ce!20885
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/members.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/api/members.rb b/lib/api/members.rb index 3d2220fed96..d23dd834c69 100644 --- a/lib/api/members.rb +++ b/lib/api/members.rb @@ -75,7 +75,10 @@ module API member = source.members.find_by(user_id: params[:user_id]) conflict!('Member already exists') if member - member = source.add_user(params[:user_id], params[:access_level], current_user: current_user, expires_at: params[:expires_at]) + user = User.find_by_id(params[:user_id]) + not_found!('User') unless user + + member = source.add_user(user, params[:access_level], current_user: current_user, expires_at: params[:expires_at]) if !member not_allowed! # This currently can only be reached in EE |