summaryrefslogtreecommitdiff
path: root/app/serializers/admin/user_entity.rb
blob: a5cf40a50b9738ff182ed3de12b3b12b6d875c64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module Admin
  class UserEntity < API::Entities::UserSafe
    include RequestAwareEntity
    include UsersHelper
    include UserActionsHelper

    expose :created_at
    expose :email
    expose :last_activity_on
    expose :avatar_url
    expose :note
    expose :badges do |user|
      user_badges_in_admin_section(user)
    end

    expose :projects_count do |user|
      user.authorized_projects.length
    end

    expose :actions do |user|
      admin_actions(user)
    end

    private

    def current_user
      options[:current_user]
    end
  end
end

Admin::UserEntity.prepend_if_ee('EE::Admin::UserEntity')