From 4acedecc7b7ba2fe0ba76464019aeaca2984655d Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Thu, 10 Nov 2016 04:08:45 +0300 Subject: Fixing the issue of visiting a project fork url giving 500 error when not signed in instead of being redirected to the sign in page. The main reason is ApplicationController skips authentication if the project exists. To fix the issue, forced the authentication in ForksController when current_user is nil. --- app/controllers/projects/forks_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index ade01c706a7..358478f90cb 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -29,8 +29,12 @@ class Projects::ForksController < Projects::ApplicationController end def new - @namespaces = current_user.manageable_namespaces - @namespaces.delete(@project.namespace) + if current_user.nil? + authenticate_user! + else + @namespaces = current_user.manageable_namespaces + @namespaces.delete(@project.namespace) + end end def create -- cgit v1.2.1 From 3b91c927195c19959afe008735a0c8f116c27826 Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Sat, 12 Nov 2016 11:16:07 +0300 Subject: Replace conditional with a guard statement. --- app/controllers/projects/forks_controller.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 358478f90cb..6892fea6eec 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -29,12 +29,9 @@ class Projects::ForksController < Projects::ApplicationController end def new - if current_user.nil? - authenticate_user! - else - @namespaces = current_user.manageable_namespaces - @namespaces.delete(@project.namespace) - end + return authenticate_user! unless current_user + @namespaces = current_user.manageable_namespaces + @namespaces.delete(@project.namespace) end def create -- cgit v1.2.1 From be6bcbe24e5dc39ab6854346708c738a5f285509 Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Sat, 12 Nov 2016 16:41:43 +0300 Subject: Temporary change --- app/controllers/projects/forks_controller.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 6892fea6eec..ade01c706a7 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -29,7 +29,6 @@ class Projects::ForksController < Projects::ApplicationController end def new - return authenticate_user! unless current_user @namespaces = current_user.manageable_namespaces @namespaces.delete(@project.namespace) end -- cgit v1.2.1 From 4c562be51842842385cd9440e6ac1cd7a97c92df Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Sat, 12 Nov 2016 16:42:36 +0300 Subject: Replaces conditional with guard statement. --- app/controllers/projects/forks_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index ade01c706a7..6892fea6eec 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -29,6 +29,7 @@ class Projects::ForksController < Projects::ApplicationController end def new + return authenticate_user! unless current_user @namespaces = current_user.manageable_namespaces @namespaces.delete(@project.namespace) end -- cgit v1.2.1 From 4b7288f19fb76f103b802ccfde848fb0a6ebc543 Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Sat, 12 Nov 2016 18:55:46 +0300 Subject: Add a new line after the guard statement to be compatible with the style guide. --- app/controllers/projects/forks_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 6892fea6eec..5151b7747ce 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -30,6 +30,7 @@ class Projects::ForksController < Projects::ApplicationController def new return authenticate_user! unless current_user + @namespaces = current_user.manageable_namespaces @namespaces.delete(@project.namespace) end -- cgit v1.2.1 From 5f2d45c956eba7e24f5f8572409230383b663bfe Mon Sep 17 00:00:00 2001 From: Cagdas Gerede Date: Tue, 15 Nov 2016 01:59:11 +0300 Subject: Add authentication for for create action. Add more tests for for new and create actions --- app/controllers/projects/forks_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/controllers/projects/forks_controller.rb') diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 5151b7747ce..ba46e2528e6 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -4,6 +4,7 @@ class Projects::ForksController < Projects::ApplicationController # Authorize before_action :require_non_empty_project before_action :authorize_download_code! + before_action :authenticate_user!, only: [:new, :create] def index base_query = project.forks.includes(:creator) @@ -29,8 +30,6 @@ class Projects::ForksController < Projects::ApplicationController end def new - return authenticate_user! unless current_user - @namespaces = current_user.manageable_namespaces @namespaces.delete(@project.namespace) end -- cgit v1.2.1