Add 'confirm' option to users api

This commit is contained in:
Matthew Monaco 2014-06-18 11:49:39 -06:00
parent d7c50b4a95
commit 5f682094d9
3 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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