Commit 5f682094 authored by Matthew Monaco's avatar Matthew Monaco

Add 'confirm' option to users api

parent d7c50b4a
...@@ -8,6 +8,7 @@ v 7.5.0 ...@@ -8,6 +8,7 @@ v 7.5.0
- Tie up loose ends with annotated tags: API & UI (Sean Edge) - Tie up loose ends with annotated tags: API & UI (Sean Edge)
- Return valid json for deleting branch via API (sponsored by O'Reilly Media) - Return valid json for deleting branch via API (sponsored by O'Reilly Media)
- Expose username in project events 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 v 7.4.2
- Fix internal snippet exposing for unauthenticated users - Fix internal snippet exposing for unauthenticated users
......
...@@ -168,6 +168,7 @@ Parameters: ...@@ -168,6 +168,7 @@ Parameters:
- `bio` (optional) - User's biography - `bio` (optional) - User's biography
- `admin` (optional) - User is admin - true or false (default) - `admin` (optional) - User is admin - true or false (default)
- `can_create_group` (optional) - User can create groups - true or false - `can_create_group` (optional) - User can create groups - true or false
- `confirm` (optional) - Require confirmation - true (default) or false
## User modification ## User modification
......
...@@ -54,15 +54,18 @@ module API ...@@ -54,15 +54,18 @@ module API
# bio - Bio # bio - Bio
# admin - User is admin - true or false (default) # admin - User is admin - true or false (default)
# can_create_group - User can create groups - true or false # can_create_group - User can create groups - true or false
# confirm - Require user confirmation - true (default) or false
# Example Request: # Example Request:
# POST /users # POST /users
post do post do
authenticated_as_admin! authenticated_as_admin!
required_attributes! [:email, :password, :name, :username] 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) user = User.build_user(attrs)
admin = attrs.delete(:admin) admin = attrs.delete(:admin)
user.admin = admin unless admin.nil? user.admin = admin unless admin.nil?
confirm = ! (attrs.delete(:confirm) =~ (/(false|f|no|0)$/i))
user.skip_confirmation! unless confirm
if user.save if user.save
present user, with: Entities::UserFull present user, with: Entities::UserFull
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment