2018-09-23 15:44:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-03-12 11:08:48 -04:00
|
|
|
class Groups::GroupMembersController < Groups::ApplicationController
|
2016-06-02 12:05:06 -04:00
|
|
|
include MembershipActions
|
2017-12-05 09:03:16 -05:00
|
|
|
include MembersPresentation
|
2016-11-16 17:37:50 -05:00
|
|
|
include SortingHelper
|
2016-06-01 12:07:23 -04:00
|
|
|
|
2018-05-21 22:59:29 -04:00
|
|
|
def self.admin_not_required_endpoints
|
|
|
|
%i[index leave request_access]
|
|
|
|
end
|
|
|
|
|
2013-06-17 09:51:43 -04:00
|
|
|
# Authorize
|
2018-05-21 22:59:29 -04:00
|
|
|
before_action :authorize_admin_group_member!, except: admin_not_required_endpoints
|
2013-06-17 09:51:43 -04:00
|
|
|
|
2019-03-20 04:17:11 -04:00
|
|
|
skip_before_action :check_two_factor_requirement, only: :leave
|
2017-12-11 09:21:06 -05:00
|
|
|
skip_cross_project_access_check :index, :create, :update, :destroy, :request_access,
|
|
|
|
:approve_access_request, :leave, :resend_invite,
|
|
|
|
:override
|
|
|
|
|
2015-03-13 11:27:51 -04:00
|
|
|
def index
|
2018-04-20 05:25:22 -04:00
|
|
|
can_manage_members = can?(current_user, :admin_group_member, @group)
|
|
|
|
|
2016-11-16 17:37:50 -05:00
|
|
|
@sort = params[:sort].presence || sort_value_name
|
2015-03-13 11:27:51 -04:00
|
|
|
@project = @group.projects.find(params[:project_id]) if params[:project_id]
|
2016-11-16 16:37:51 -05:00
|
|
|
|
2017-02-08 10:02:25 -05:00
|
|
|
@members = GroupMembersFinder.new(@group).execute
|
2018-04-20 05:25:22 -04:00
|
|
|
@members = @members.non_invite unless can_manage_members
|
2016-11-16 16:37:51 -05:00
|
|
|
@members = @members.search(params[:search]) if params[:search].present?
|
2018-04-04 05:19:47 -04:00
|
|
|
@members = @members.sort_by_attribute(@sort)
|
2018-04-20 05:25:22 -04:00
|
|
|
|
|
|
|
if can_manage_members && params[:two_factor].present?
|
|
|
|
@members = @members.filter_by_2fa(params[:two_factor])
|
|
|
|
end
|
|
|
|
|
2016-10-18 08:22:18 -04:00
|
|
|
@members = @members.page(params[:page]).per(50)
|
2018-07-16 12:18:52 -04:00
|
|
|
@members = present_members(@members)
|
2016-11-16 16:37:51 -05:00
|
|
|
|
2017-12-05 09:03:16 -05:00
|
|
|
@requesters = present_members(
|
|
|
|
AccessRequestsFinder.new(@group).execute(current_user))
|
2015-11-17 09:51:40 -05:00
|
|
|
|
|
|
|
@group_member = @group.group_members.new
|
2015-03-13 11:27:51 -04:00
|
|
|
end
|
2013-06-17 09:51:43 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
# MembershipActions concern
|
|
|
|
alias_method :membershipable, :group
|
2013-06-17 09:51:43 -04:00
|
|
|
end
|