summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-21 15:48:00 +0000
committerRémy Coutable <remy@rymai.me>2017-11-21 15:48:00 +0000
commit9961ac033f091269b983de6887dc845ebe35fb5a (patch)
tree4171348087b509348c59bb7d35f55fe6f5972f81
parent28a5f5f2e91297a56369c39e96be25187ad0a1dd (diff)
parent0b9e1e16626eff4cd8ae43ce47ec0f965beaf843 (diff)
downloadgitlab-ce-9961ac033f091269b983de6887dc845ebe35fb5a.tar.gz
Merge branch 'skip_confirmation_user_API' into 'master'
Skip confirmation user api Closes #28934 See merge request gitlab-org/gitlab-ce!15175
-rw-r--r--app/models/user.rb4
-rw-r--r--changelogs/unreleased/skip_confirmation_user_API.yml7
-rw-r--r--doc/api/users.md1
-rw-r--r--lib/api/users.rb3
-rw-r--r--spec/requests/api/users_spec.rb8
5 files changed, 22 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 0329d094d09..f98165754ca 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -445,6 +445,10 @@ class User < ActiveRecord::Base
skip_confirmation! if bool
end
+ def skip_reconfirmation=(bool)
+ skip_reconfirmation! if bool
+ end
+
def generate_reset_token
@reset_token, enc = Devise.token_generator.generate(self.class, :reset_password_token)
diff --git a/changelogs/unreleased/skip_confirmation_user_API.yml b/changelogs/unreleased/skip_confirmation_user_API.yml
new file mode 100644
index 00000000000..144ccd69e68
--- /dev/null
+++ b/changelogs/unreleased/skip_confirmation_user_API.yml
@@ -0,0 +1,7 @@
+---
+title: Add email confirmation parameters for user creation and update via API
+merge_request:
+author: Daniel Juarez
+type: added
+
+
diff --git a/doc/api/users.md b/doc/api/users.md
index aa711090af1..478d747a50d 100644
--- a/doc/api/users.md
+++ b/doc/api/users.md
@@ -297,6 +297,7 @@ Parameters:
- `location` (optional) - User's location
- `admin` (optional) - User is admin - true or false (default)
- `can_create_group` (optional) - User can create groups - true or false
+- `skip_reconfirmation` (optional) - Skip reconfirmation - true or false (default)
- `external` (optional) - Flags the user as external - true or false(default)
- `avatar` (optional) - Image file for user's avatar
diff --git a/lib/api/users.rb b/lib/api/users.rb
index d80b364bd09..0cd89b1bcf8 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -31,7 +31,6 @@ module API
optional :location, type: String, desc: 'The location of the user'
optional :admin, type: Boolean, desc: 'Flag indicating the user is an administrator'
optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups'
- optional :skip_confirmation, type: Boolean, default: false, desc: 'Flag indicating the account is confirmed'
optional :external, type: Boolean, desc: 'Flag indicating the user is an external user'
optional :avatar, type: File, desc: 'Avatar image for user'
all_or_none_of :extern_uid, :provider
@@ -101,6 +100,7 @@ module API
requires :email, type: String, desc: 'The email of the user'
optional :password, type: String, desc: 'The password of the new user'
optional :reset_password, type: Boolean, desc: 'Flag indicating the user will be sent a password reset token'
+ optional :skip_confirmation, type: Boolean, desc: 'Flag indicating the account is confirmed'
at_least_one_of :password, :reset_password
requires :name, type: String, desc: 'The name of the user'
requires :username, type: String, desc: 'The username of the user'
@@ -134,6 +134,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
optional :email, type: String, desc: 'The email of the user'
optional :password, type: String, desc: 'The password of the new user'
+ optional :skip_reconfirmation, type: Boolean, desc: 'Flag indicating the account skips the confirmation by email'
optional :name, type: String, desc: 'The name of the user'
optional :username, type: String, desc: 'The username of the user'
use :optional_attributes
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 2aeae6f9ec7..2428e63e149 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -510,6 +510,14 @@ describe API::Users do
expect(user.reload.notification_email).to eq('new@email.com')
end
+ it 'skips reconfirmation when requested' do
+ put api("/users/#{user.id}", admin), { skip_reconfirmation: true }
+
+ user.reload
+
+ expect(user.confirmed_at).to be_present
+ end
+
it 'updates user with his own username' do
put api("/users/#{user.id}", admin), username: user.username