summaryrefslogtreecommitdiff
path: root/lib/api/users.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 6ed2740c333..92dbe97f0a4 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -13,7 +13,12 @@ module API
@users = @users.active if params[:active].present?
@users = @users.search(params[:search]) if params[:search].present?
@users = paginate @users
- present @users, with: Entities::User
+
+ if current_user.is_admin?
+ present @users, with: Entities::UserFull
+ else
+ present @users, with: Entities::UserBasic
+ end
end
# Get a single user
@@ -24,7 +29,12 @@ module API
# GET /users/:id
get ":id" do
@user = User.find(params[:id])
- present @user, with: Entities::User
+
+ if current_user.is_admin?
+ present @user, with: Entities::UserFull
+ else
+ present @user, with: Entities::UserBasic
+ end
end
# Create user. Available only for admin
@@ -53,7 +63,7 @@ module API
admin = attrs.delete(:admin)
user.admin = admin unless admin.nil?
if user.save
- present user, with: Entities::User
+ present user, with: Entities::UserFull
else
not_found!
end
@@ -87,7 +97,7 @@ module API
admin = attrs.delete(:admin)
user.admin = admin unless admin.nil?
if user.update_attributes(attrs, as: :admin)
- present user, with: Entities::User
+ present user, with: Entities::UserFull
else
not_found!
end