From 13d71ec0a5adcbce3a18807967a6abf0b2df449b 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 6f9f97ad6f3..bdd69e1aeac 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -24,7 +24,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 @@ -196,10 +197,15 @@ class GroupsController < Groups::ApplicationController 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