2018-11-27 10:10:40 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserPresenter < Gitlab::View::Presenter::Delegated
|
2021-09-21 05:12:21 -04:00
|
|
|
presents ::User, as: :user
|
2020-12-07 16:10:08 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-04-06 20:09:26 -04:00
|
|
|
def can?(*args)
|
|
|
|
user.can?(*args)
|
|
|
|
end
|
|
|
|
|
2020-12-07 16:10:08 -05:00
|
|
|
def should_be_private?
|
2021-04-06 20:09:26 -04:00
|
|
|
!Ability.allowed?(current_user, :read_user_profile, user)
|
2020-12-07 16:10:08 -05:00
|
|
|
end
|
2018-11-27 10:10:40 -05:00
|
|
|
end
|