Class: Organizations::CreateService

Inherits:
BaseService show all
Defined in:
app/services/organizations/create_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from Organizations::BaseService

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/organizations/create_service.rb', line 5

def execute
  return error_no_permissions unless can?(current_user, :create_organization)
  return error_feature_flag unless Feature.enabled?(:allow_organization_creation, current_user)

  add_organization_owner_attributes
  organization = Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification
                   .allow_cross_database_modification_within_transaction(
                     url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/438757'
                   ) do
    Organization.create(params)
  end

  if organization.persisted?
    ServiceResponse.success(payload: { organization: organization })
  else
    error_creating(organization)
  end
end