diff options
author | Steve Norman <steve.norman@thomsonreuters.com> | 2015-04-28 19:02:44 +0300 |
---|---|---|
committer | Steve Norman <steve.norman@thomsonreuters.com> | 2015-07-03 14:17:57 +0300 |
commit | b3a751112ded889769dadc7cc69d2d1467aa9471 (patch) | |
tree | cc9f635e07f0ad0b74ae1d5b45b14f1eeebed236 /lib | |
parent | 49749169e9b442c13cdc279d7e783f65a3afc794 (diff) |
Allow user to be blocked and unblocked via the API
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/users.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index 9b268cfe8bc..c468371d3d4 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -199,6 +199,36 @@ module API not_found!('User') end end + + # Block user. Available only for admin + # + # Example Request: + # PUT /users/:id/block + put ':id/block' do + authenticated_as_admin! + user = User.find_by(id: params[:id]) + + if user + user.block + else + not_found!('User') + end + end + + # Unblock user. Available only for admin + # + # Example Request: + # PUT /users/:id/unblock + put ':id/unblock' do + authenticated_as_admin! + user = User.find_by(id: params[:id]) + + if user + user.activate + else + not_found!('User') + end + end end resource :user do |