diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2017-01-04 11:35:46 +0100 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2017-01-04 11:35:46 +0100 |
commit | 091e66ebe3e63ad18075b10c44f36cb2e98d9f32 (patch) | |
tree | 0db83baed04dfa26ac2a328c3371a0d2a538b595 | |
parent | 115aac77f614a9130aa9bc6ff48aed47339aebfc (diff) | |
download | gitlab-ce-api-fix-user-creation.tar.gz |
API: Fix user creation with external identityapi-fix-user-creation
-rw-r--r-- | changelogs/unreleased/api-fix-user-creation.yml | 4 | ||||
-rw-r--r-- | lib/api/users.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/users_spec.rb | 10 |
3 files changed, 16 insertions, 0 deletions
diff --git a/changelogs/unreleased/api-fix-user-creation.yml b/changelogs/unreleased/api-fix-user-creation.yml new file mode 100644 index 00000000000..a10b5a432ad --- /dev/null +++ b/changelogs/unreleased/api-fix-user-creation.yml @@ -0,0 +1,4 @@ +--- +title: 'API: Fix user creation with external identity' +merge_request: 8435 +author: Robert Schilling diff --git a/lib/api/users.rb b/lib/api/users.rb index de07fbf59fc..26b44eb7b81 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -92,6 +92,8 @@ module API # Filter out params which are used later identity_attrs = params.slice(:provider, :extern_uid) + params.delete(:provider) + params.delete(:extern_uid) confirm = params.delete(:confirm) user = User.new(declared_params(include_missing: false)) diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 45b7988a054..eccc8766777 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -181,6 +181,16 @@ describe API::Users, api: true do expect(new_user.external).to be_truthy end + it 'creates an user with an external provider' do + post api('/users', admin), attributes_for(:user, provider: 'github', extern_uid: 'john') + + expect(response).to have_http_status(201) + new_user = User.find(json_response['id']) + expect(new_user).not_to eq(nil) + expect(new_user.identities.first.provider).to eq('github') + expect(new_user.identities.first.extern_uid).to eq('john') + end + it "does not create user with invalid email" do post api('/users', admin), email: 'invalid email', |