summaryrefslogtreecommitdiff
path: root/app/presenters/user_presenter.rb
blob: 7cd94082bacbb482dfe54fafd4a1edc497ad3bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class UserPresenter < Gitlab::View::Presenter::Delegated
  presents :user

  def group_memberships
    should_be_private? ? GroupMember.none : user.group_members
  end

  def project_memberships
    should_be_private? ? ProjectMember.none : user.project_members
  end

  private

  def can?(*args)
    user.can?(*args)
  end

  def should_be_private?
    !Ability.allowed?(current_user, :read_user_profile, user)
  end
end