Skip to content
Snippets Groups Projects

Group master can manage group members

Closed gitlab-qa-bot requested to merge github/fork/timmjd/request/group_master_role into master

Created by: timmjd

In the current implementation only Group Owner can manage users within a group.

This change will grand Group Master to manage users within a group. It will also prevent a master to add a user with a higher access role then it's own (Master cannot create Owner, only Owner can create Owner).

Use case for this change is a distributed teams where you have localized managers who are responsible for group setup but should not be able to do operations like deletion of repositories.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Unable to load the diff
  • Created by: houndci-bot

    Line is too long. [102/80]

    By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

    By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    • Created by: houndci-bot

      Line is too long. [82/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • Unable to load the diff
    • Created by: houndci-bot

      Space missing after comma.
      Space between { and | missing.
      Space missing inside }.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    80 end
    • Created by: houndci-bot

      Use a guard clause instead of wrapping the code inside a conditional expression.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    • Created by: houndci-bot

      Line is too long. [82/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    • Created by: houndci-bot

      Line is too long. [82/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 7 7 layout 'group'
    8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    • Created by: houndci-bot

      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 7 7 layout 'group'
    8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    • Created by: houndci-bot

      Line is too long. [86/80]
      Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    16 22 @member = @group.users_groups.find(params[:id])
    17 @member.update_attributes(member_params)
    23
    24 if @current_users_group_roles.has_value?(params[:users_group]["group_access"].to_i)
    25 @member.update_attributes(member_params)
    26 end
    • Created by: houndci-bot

      Use a guard clause instead of wrapping the code inside a conditional expression.
      Line is too long. [87/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    • Created by: houndci-bot

      Use a guard clause instead of wrapping the code inside a conditional expression.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • Unable to load the diff
    • Created by: houndci-bot

      Space missing after comma.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    • Created by: jvanbaarsen

      Can you please fix this point?

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 7 7 layout 'group'
    8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    • Created by: jvanbaarsen

      What do you think about: current_users_group = UsersGroup.where(user: current_user, group: group).first ? Might be a little bit more expressive

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    16 22 @member = @group.users_groups.find(params[:id])
    • Created by: jvanbaarsen

      Same as above

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 7 7 layout 'group'
    8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    • Created by: houndci-bot

      Line is too long. [102/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    • Created by: houndci-bot

      Line is too long. [102/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    80 end
    81
    82 current_users_group = group.users_groups.where(user_id: current_user.id).first
    83 @current_users_group_roles = {}
    • Created by: houndci-bot

      Never use unless with else. Rewrite these with the positive case first.

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    80 end
    81
    82 current_users_group = group.users_groups.where(user_id: current_user.id).first
    • Created by: houndci-bot

      Line is too long. [82/80]

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • gitlab-qa-bot
  • 74 74
    75 75 @members = @members.order('group_access DESC').page(params[:page]).per(50)
    76 76 @users_group = UsersGroup.new
    77
    78 if current_user.nil?
    79 return
    80 end
    81
    82 current_users_group = group.users_groups.where(user_id: current_user.id).first
    83 @current_users_group_roles = {}
    • Created by: jvanbaarsen

      Can you please rewrite this statement?

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab project)

      By Administrator on 2014-08-02T13:11:56 (imported from GitLab)

  • Created by: timmjd

    It seems that the current test setup will fail random If I tun them multiple times they will past. Also I don't think the failure is related to the content of this pull request

    By Administrator on 2014-07-18T20:31:36 (imported from GitLab project)

    By Administrator on 2014-07-18T20:31:36 (imported from GitLab)

  • Created by: jvanbaarsen

    @timmjd Can you please squash this commits?

    By Administrator on 2014-08-02T10:39:30 (imported from GitLab project)

    By Administrator on 2014-08-02T10:39:30 (imported from GitLab)

  • gitlab-qa-bot
  • 7 7 layout 'group'
    8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    • Created by: houndci-bot

      Line is too long. [86/80]

      By Administrator on 2014-08-02T13:12:02 (imported from GitLab project)

      By Administrator on 2014-08-02T13:12:02 (imported from GitLab)

  • gitlab-qa-bot
  • 113 113 response.status.should == 200
    114 114 end
    115 115
    116 it "should not remove a group if not an owner" do
    116 it "should not remove a group if a developer" do
    • Created by: houndci-bot

      Prefer single-quoted strings when you don't need string interpolation or special symbols.

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab project)

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab)

  • gitlab-qa-bot
  • 45 45 group_access
    46 46 end
    47 47
    48 def access_roles
    49 Gitlab::Access.options_with_owner.select { |k, v| v <= group_access }
    • Created by: houndci-bot

      Unused block argument - k. If it's necessary, use _ or _k as an argument name to indicate that it won't be used.

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab project)

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab)

  • gitlab-qa-bot
  • 11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    16 22 @member = @group.users_groups.find(params[:id])
    17 @member.update_attributes(member_params)
    23
    24 if @current_users_group_roles.has_value?(params[:users_group]["group_access"].to_i)
    • Created by: houndci-bot

      Line is too long. [87/80]
      Prefer single-quoted strings when you don't need string interpolation or special symbols.

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab project)

      By Administrator on 2014-08-02T13:12:03 (imported from GitLab)

  • Created by: timmjd

    Commit squashed into a single one.

    By Administrator on 2014-08-05T14:54:59 (imported from GitLab project)

    By Administrator on 2014-08-05T14:54:59 (imported from GitLab)

  • Created by: timmjd

    Commit squashed. Please accept or reject it

    By Administrator on 2014-08-17T12:19:58 (imported from GitLab project)

    By Administrator on 2014-08-17T12:19:58 (imported from GitLab)

  • Created by: jvanbaarsen

    @timmjd THanks! @randx Its good for merging!

    By Administrator on 2014-08-17T12:21:31 (imported from GitLab project)

    By Administrator on 2014-08-17T12:21:31 (imported from GitLab)

  • Created by: dzaporozhets

    I like the idea. I will do code review a bit later

    By Administrator on 2014-08-28T06:27:58 (imported from GitLab project)

    By Administrator on 2014-08-28T06:27:58 (imported from GitLab)

  • gitlab-qa-bot
  • 194 194 # Only group masters and group owners can create new projects in group
    195 195 if group.has_master?(user) || group.has_owner?(user) || user.admin?
    196 196 rules += [
    197 :manage_group,
    • Created by: dzaporozhets

      dont give masters manage_group permission. It allows also remove group. Create new manage_group_members rule

      By Administrator on 2014-09-01T11:19:25 (imported from GitLab project)

      By Administrator on 2014-09-01T11:19:25 (imported from GitLab)

  • gitlab-qa-bot
  • 45 45 group_access
    46 46 end
    47 47
    48 def access_roles
    49 Gitlab::Access.options_with_owner.select { |k, v| v <= group_access }
    • Created by: dzaporozhets

      use readable variable names. No k, v, a, x, y

      By Administrator on 2014-09-01T11:20:28 (imported from GitLab project)

      By Administrator on 2014-09-01T11:20:28 (imported from GitLab)

  • gitlab-qa-bot
  • 8 8
    9 9 def create
    10 @group.add_users(params[:user_ids].split(','), params[:group_access])
    10 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    11 11
    12 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    12 if @current_users_group_roles.has_value?(params[:group_access].to_i)
    13 @group.add_users(params[:user_ids].split(','), params[:group_access])
    14 redirect_to members_group_path(@group), notice: 'Users were successfully added.'
    15 else
    16 redirect_to members_group_path(@group)
    17 end
    13 18 end
    14 19
    15 20 def update
    21 @current_users_group_roles = UsersGroup.where(user: current_user, group: group).first.access_roles
    • Created by: dzaporozhets

      Is it possible a case when UsersGroup.where(user: current_user, group: group).first returns nil? Ex when admin without group membership access this page? Because in this case nil.access_roles will raise exception

      By Administrator on 2014-09-01T11:22:39 (imported from GitLab project)

      By Administrator on 2014-09-01T11:22:39 (imported from GitLab)

  • Created by: dzaporozhets

    @timmjd please fix my comments and ping me. I would like to merge this :)

    By Administrator on 2014-09-03T11:05:12 (imported from GitLab project)

    By Administrator on 2014-09-03T11:05:12 (imported from GitLab)

  • Created by: dblessing

    @timmjd do you have time to address the comments?

    By Administrator on 2014-10-24T03:14:48 (imported from GitLab project)

    By Administrator on 2014-10-24T03:14:48 (imported from GitLab)

  • Created by: dblessing

    This merge request has been closed because a request for more information has not been reacted to for more than 2 weeks. If you respond and conform to the merge request guidelines in our contributing guidelines we will reopen this merge request.

    By Administrator on 2014-11-11T14:24:06 (imported from GitLab project)

    By Administrator on 2014-11-11T14:24:06 (imported from GitLab)

  • Please register or sign in to reply
    Loading