developer user run into 404 when create project using group project template

Summary

When a developer in a group create a project outside the subgroup used for Custom group-level project templates, the project will be created successfully but the screen will show 404 page for developer.

Steps to reproduce

(How one can reproduce the issue - this is very important)

  1. Create a groupA
  2. Add userA to the group with developer permission
  3. Create a subgroup1
  4. Create a subgroup2
  5. Create a project1 in the subgroup1 and create a file in the project1 as well
  6. In groupA go to Settings > General > Custom project templates > set groupA/subgroup1 as Custom project templates > Save changes
  7. Do the following as userA
  8. Go to groupA or subgroup2
  9. Click on New project > Choose from template > Group > project1 > Use template
  10. Type in a new project name > make sure project URL is in either groupA or groupA/subgroup2 but not groupA/subgroup1
  11. Click on Create project > Observe 404 page
  12. Go to the namespace where the new project was create and see the project was created successfully from the template

Example Project

(If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report)

(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)

What is the current bug behavior?

Project creation is successful but the 404 page is shown

What is the expected correct behavior?

Project is created and load the project page

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.) Screen_Shot_2019-12-12_at_1.35.14_PM

Output of checks

GitLab.com, GitLab Enterprise Edition 12.6.0-pre fa093de6

Edited by Haris Delalić