From d2edd70173de1f20dc8de927f2e335f4133f663c Mon Sep 17 00:00:00 2001 From: Daniel Gerhardt Date: Mon, 4 May 2015 13:50:23 +0200 Subject: [PATCH] Prevent group names of length < 5 when updating settings This restriction does not apply to admins. --- app/controllers/groups_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e57ef452c63..605b52fa007 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -19,7 +19,8 @@ class GroupsController < Groups::ApplicationController before_action :user_actions, only: [:show] - before_filter :validate_name, only: :create + before_filter :validate_name, only: [:create, :update] + skip_cross_project_access_check :index, :new, :create, :edit, :update, :destroy, :projects @@ -185,10 +186,15 @@ def user_actions end def validate_name - @group = Group.new(group_params) - unless @group.path.empty? || @group.path.length > 4 || current_user.admin? + group = Group.new(group_params) + unless group.path.empty? || group.path.length > 4 || current_user.admin? flash.now[:alert] = 'Path must have at least a length of 5.' - render action: "new" + if action_name == 'update' + render action: 'edit' + else + @group = group + render action: 'new' + end end end -- GitLab