diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-25 00:07:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-25 00:07:21 +0300 |
commit | 1881f0ee95e0d293285dac5d9c1231e45b841963 (patch) | |
tree | dffb84ced11a1caa2f3d00efd16648651f320e9d /app | |
parent | 80b22a4413679216b470c7a4e9fefd0eb928add5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 12 | ||||
-rw-r--r-- | app/services/users/build_service.rb | 2 |
2 files changed, 13 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") diff --git a/app/services/users/build_service.rb b/app/services/users/build_service.rb index b51684c6899..2a9e4be91d3 100644 --- a/app/services/users/build_service.rb +++ b/app/services/users/build_service.rb @@ -36,6 +36,8 @@ module Users else standard_build_user end + + user.assign_personal_namespace end def admin? |