Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix resetting the session for non-html requests

Oliver Günther91ecb3ba1e89
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3458b7f894e..b55292988a6 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -272,11 +272,14 @@ class ApplicationController < ActionController::Base
def require_login
unless User.current.logged?
- # Ensure we reset the session to terminate any old session objects
- reset_session
-
respond_to do |format|
- format.any(:html, :atom) { redirect_to main_app.signin_path(back_url: login_back_url) }
+ format.any(:html, :atom) do
+ # Ensure we reset the session to terminate any old session objects
+ # but ONLY for html requests to avoid double-resetting sessions
+ reset_session
+
+ redirect_to main_app.signin_path(back_url: login_back_url)
+ end
auth_header = OpenProject::Authentication::WWWAuthenticate.response_header(request_headers: request.headers)