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/services/projects/create_service.rb')
-rw-r--r--app/services/projects/create_service.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 6381ee67ce7..c72f9b4b602 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -96,7 +96,7 @@ module Projects
log_info("#{current_user.name} created a new project \"#{@project.full_name}\"")
if @project.import?
- experiment(:combined_registration, user: current_user).track(:import_project)
+ Gitlab::Tracking.event(self.class.name, 'import_project', user: current_user)
else
# Skip writing the config for project imports/forks because it
# will always fail since the Git directory doesn't exist until
@@ -158,14 +158,25 @@ module Projects
priority: UserProjectAccessChangedService::LOW_PRIORITY
)
else
- @project.add_owner(@project.namespace.owner, current_user: current_user)
+ owner_user = @project.namespace.owner
+ owner_member = @project.add_owner(owner_user, current_user: current_user)
+
+ # There is a possibility that the sidekiq job to refresh the authorizations of the owner_user in this project
+ # isn't picked up (or finished) by the time the user is redirected to the newly created project's page.
+ # If that happens, the user will hit a 404. To avoid that scenario, we manually create a `project_authorizations` record for the user here.
+ if owner_member.persisted?
+ owner_user.project_authorizations.safe_find_or_create_by(
+ project: @project,
+ access_level: ProjectMember::OWNER
+ )
+ end
# During the process of adding a project owner, a check on permissions is made on the user which caches
# the max member access for that user on this project.
# Since that is `0` before the member is created - and we are still inside the request
# cycle when we need to do other operations that might check those permissions (e.g. write a commit)
# we need to purge that cache so that the updated permissions is fetched instead of using the outdated cached value of 0
# from before member creation
- @project.team.purge_member_access_cache_for_user_id(@project.namespace.owner.id)
+ @project.team.purge_member_access_cache_for_user_id(owner_user.id)
end
end