Skip to content

Fixing the issue of visiting a project fork url giving 500 error when not signed…

What does this MR do?

It redirects the user to the sign in page if the user visits the project/fork/new url without signin in.

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

As described in the issue https://gitlab.com/gitlab-org/gitlab-ce/issues/24302, visiting the project/forks/new URL results in a 500 error when not signed in. The expected behavior would be redirecting the user to the sign in page. The main reason behind the bug is that in the ForksController's "new" method, the current_user object is accessed and when it is nil, this causes an exception. The reason why the current_user is nil is because in Projects::ApplicationController from which ForksController is derived, we have "skip_before_action authenticate_user". Inside the same controller, the project method has some checks for current_user; however, in the scenario causing this bug, the project field (@Project) has a valid value so those checks are not performed. As a solution, this patch authenticates the user if the current_user is nil inside the "new" method of ForksController.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/24302

Merge request reports