summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Monaco <matt@monaco.cx>2014-06-18 11:49:39 -0600
committerMatthew Monaco <matt@monaco.cx>2014-11-03 15:37:13 -0700
commit5f682094d9b7c985ad62ebe29664bb6fe87b54be (patch)
treeb5b50566c04a62ea186da1ce41d3634fb015b125
parentd7c50b4a95b5530ae0e2f5249cfd9a419dd940c6 (diff)
downloadgitlab-ce-5f682094d9b7c985ad62ebe29664bb6fe87b54be.tar.gz
Add 'confirm' option to users api
-rw-r--r--CHANGELOG1
-rw-r--r--doc/api/users.md1
-rw-r--r--lib/api/users.rb5
3 files changed, 6 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5dab8c864e7..5298e137d60 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@ v 7.5.0
- Tie up loose ends with annotated tags: API & UI (Sean Edge)
- Return valid json for deleting branch via API (sponsored by O'Reilly Media)
- Expose username in project events API (sponsored by O'Reilly Media)
+ - Allow user confirmation to be skipped for new users via API
v 7.4.2
- Fix internal snippet exposing for unauthenticated users
diff --git a/doc/api/users.md b/doc/api/users.md
index 3fdd3a75e88..fec5deebee4 100644
--- a/doc/api/users.md
+++ b/doc/api/users.md
@@ -168,6 +168,7 @@ Parameters:
- `bio` (optional) - User's biography
- `admin` (optional) - User is admin - true or false (default)
- `can_create_group` (optional) - User can create groups - true or false
+- `confirm` (optional) - Require confirmation - true (default) or false
## User modification
diff --git a/lib/api/users.rb b/lib/api/users.rb
index d07815a8a97..1a4a8535d48 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -54,15 +54,18 @@ module API
# bio - Bio
# admin - User is admin - true or false (default)
# can_create_group - User can create groups - true or false
+ # confirm - Require user confirmation - true (default) or false
# Example Request:
# POST /users
post do
authenticated_as_admin!
required_attributes! [:email, :password, :name, :username]
- attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :admin]
+ attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :confirm, :admin]
user = User.build_user(attrs)
admin = attrs.delete(:admin)
user.admin = admin unless admin.nil?
+ confirm = ! (attrs.delete(:confirm) =~ (/(false|f|no|0)$/i))
+ user.skip_confirmation! unless confirm
if user.save
present user, with: Entities::UserFull
else