Commit b7d5c749 authored by Daniel Gerhardt's avatar Daniel Gerhardt

Forbid creation of groups with a path length < 5

This restriction does not apply to admins.
parent 844f1692
......@@ -16,6 +16,8 @@ class GroupsController < Groups::ApplicationController
before_action :group_projects, only: [:show, :projects, :activity, :issues, :merge_requests]
before_action :event_filter, only: [:activity]
before_filter :validate_name, only: :create
layout :determine_layout
def index
......@@ -129,4 +131,12 @@ class GroupsController < Groups::ApplicationController
@events = event_filter.apply_filter(@events).with_associations
@events = @events.limit(20).offset(params[:offset] || 0)
end
def validate_name
@group = Group.new(group_params)
unless @group.path.empty? || @group.path.length > 4 || current_user.is_admin?
flash.now[:alert] = 'Path must have at least a length of 5.'
render action: "new"
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment