diff options
| author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-22 21:01:50 +0200 |
|---|---|---|
| committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-22 21:01:50 +0200 |
| commit | 8c8f6db4578051300794c7032bc63d68f70cce16 (patch) | |
| tree | f48f82ed1418ff9a6d810b4f354629d7a275b606 /lib/api/users.rb | |
| parent | a8231ea1befd803fb5892ea3e6679219f5d7d8e5 (diff) | |
| parent | 1005389f70070245092c1ae5f3f9b10b8e7c102e (diff) | |
| download | gitlab-ce-8c8f6db4578051300794c7032bc63d68f70cce16.tar.gz | |
Merge branch 'master' into feature/gb/manual-actions-protected-branches-permissions
* master: (274 commits)
Update VERSION to 9.2.0-pre
Update CHANGELOG.md for 9.1.0
Update Auto Deploy documentation
Disable import URL field in New project form since it's hidden by default
Remove reference to burndown charts since they don't exist for ce.
Use master_password for Sentinel
Refactor Discussions docs
Start versioning cached markdown fields
Refactor add_users method for project and group
Improved the spec Now correctly tests against different forms
Refactor environments components into vue files - part 3
Adding animation for all dropdown
fix placeholder visibility
submodule_links: handle urls that don't end with .git
Add help regarding vue resource and where to include it
Append .json to ajax endpoint to prevent browser to display raw json
Fixed the preview keyboard shortcut focusing wrong tab
Fix broken link
Added new discussions docs
Started on resolvable discussions docs
...
Diffstat (limited to 'lib/api/users.rb')
| -rw-r--r-- | lib/api/users.rb | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index eedc59f8636..46f221f68fe 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -39,10 +39,13 @@ module API params do # CE optional :username, type: String, desc: 'Get a single user with a specific username' + optional :extern_uid, type: String, desc: 'Get a single user with a specific external authentication provider UID' + optional :provider, type: String, desc: 'The external provider' optional :search, type: String, desc: 'Search for a username' optional :active, type: Boolean, default: false, desc: 'Filters only active users' optional :external, type: Boolean, default: false, desc: 'Filters only external users' optional :blocked, type: Boolean, default: false, desc: 'Filters only blocked users' + all_or_none_of :extern_uid, :provider use :pagination end @@ -51,14 +54,17 @@ module API render_api_error!("Not authorized.", 403) end - if params[:username].present? - users = User.where(username: params[:username]) - else - users = User.all - users = users.active if params[:active] - users = users.search(params[:search]) if params[:search].present? - users = users.blocked if params[:blocked] - users = users.external if params[:external] && current_user.admin? + authenticated_as_admin! if params[:external].present? || (params[:extern_uid].present? && params[:provider].present?) + + users = User.all + users = User.where(username: params[:username]) if params[:username] + users = users.active if params[:active] + users = users.search(params[:search]) if params[:search].present? + users = users.blocked if params[:blocked] + + if current_user.admin? + users = users.joins(:identities).merge(Identity.with_extern_uid(params[:provider], params[:extern_uid])) if params[:extern_uid] && params[:provider] + users = users.external if params[:external] end entity = current_user.admin? ? Entities::UserPublic : Entities::UserBasic @@ -534,6 +540,21 @@ module API email.destroy current_user.update_secondary_emails! end + + desc 'Get a list of user activities' + params do + optional :from, type: DateTime, default: 6.months.ago, desc: 'Date string in the format YEAR-MONTH-DAY' + use :pagination + end + get "activities" do + authenticated_as_admin! + + activities = User. + where(User.arel_table[:last_activity_on].gteq(params[:from])). + reorder(last_activity_on: :asc) + + present paginate(activities), with: Entities::UserActivity + end end end end |
