From b0d24ab1b52a78bf855a70886113b79707036029 Mon Sep 17 00:00:00 2001 From: evuez Date: Wed, 24 Feb 2016 13:14:37 +0100 Subject: Add fields to GET /users/* API endpoints for admins Added fields are last_sign_in_at and confirmed_at. They are available for GET /users/ and GET /users/:id for admins. Closes #840 --- CHANGELOG | 1 + doc/api/users.md | 2 ++ lib/api/entities.rb | 2 ++ spec/requests/api/users_spec.rb | 2 ++ 4 files changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d61c5e74f3a..0bbcd6b867e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ v 8.6.0 (unreleased) - Fix avatar stretching by providing a cropping feature (Johann Pardanaud) - Don't load all of GitLab in mail_room - Strip leading and trailing spaces in URL validator (evuez) + - Add "last_sign_in_at" and "confirmed_at" to GET /users/* API endpoints for admins (evuez) - Return empty array instead of 404 when commit has no statuses in commit status API - Update documentation to reflect Guest role not being enforced on internal projects - Allow search for logged out users diff --git a/doc/api/users.md b/doc/api/users.md index b7fc903825e..82c57a2fd43 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -151,6 +151,8 @@ Parameters: "name": "John Smith", "state": "active", "created_at": "2012-05-23T08:00:58Z", + "confirmed_at": "2012-05-23T08:00:58Z", + "last_sign_in_at": "2015-03-23T08:00:58Z", "bio": null, "skype": "", "linkedin": "", diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b021db8fa5b..0779fb881a0 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -23,6 +23,8 @@ module API end class UserFull < User + expose :last_sign_in_at + expose :confirmed_at expose :email expose :theme_id, :color_scheme_id, :projects_limit, :current_sign_in_at expose :identities, using: Entities::Identity diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index b82c5c7685f..96e8c8c51f8 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -47,6 +47,8 @@ describe API::API, api: true do expect(json_response.first.keys).to include 'identities' expect(json_response.first.keys).to include 'can_create_project' expect(json_response.first.keys).to include 'two_factor_enabled' + expect(json_response.first.keys).to include 'last_sign_in_at' + expect(json_response.first.keys).to include 'confirmed_at' end end end -- cgit v1.2.1