Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index a7c90765be1..b9dbba27a94 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -151,6 +151,7 @@ class User < MainClusterwide::ApplicationRecord
# Namespace for personal projects
has_one :namespace,
-> { where(type: Namespaces::UserNamespace.sti_name) },
+ required: true,
dependent: :destroy, # rubocop:disable Cop/ActiveRecordDependent
foreign_key: :owner_id,
inverse_of: :owner,
@@ -1602,7 +1603,7 @@ class User < MainClusterwide::ApplicationRecord
if namespace
namespace.path = username if username_changed?
namespace.name = name if name_changed?
- else
+ elsif Feature.disabled?(:create_user_ns_outside_model)
# TODO: we should no longer need the `type` parameter once we can make the
# the `has_one :namespace` association use the correct class.
# issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
@@ -1611,6 +1612,15 @@ class User < MainClusterwide::ApplicationRecord
end
end
+ def assign_personal_namespace
+ return namespace if namespace
+
+ build_namespace(path: username, name: name)
+ namespace.build_namespace_settings
+
+ namespace
+ end
+
def set_username_errors
namespace_path_errors = self.errors.delete(:"namespace.path")