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

Only set the omniauth back_url during direct login

Oliver Günther1fb14d119c43
diff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rb
index 05219a5c314..61adf240a69 100644
--- a/app/controllers/concerns/accounts/omniauth_login.rb
+++ b/app/controllers/concerns/accounts/omniauth_login.rb
@@ -47,6 +47,13 @@ module Accounts::OmniauthLogin
end
def omniauth_login
+ # Remmember the back_url to redirect to after login
+ # only if we're in a direct login phase, so the user ends up
+ # in the original requested URL after logging in
+ if omniauth_direct_login?
+ params[:back_url] = request.env['omniauth.origin']
+ end
+
# Extract auth info and perform check / login or activate user
auth_hash = request.env['omniauth.auth']
handle_omniauth_authentication(auth_hash)
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index 3ca237e7590..4648b0291c0 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -87,7 +87,7 @@ RSpec.describe 'Omniauth authentication' do
fill_in('email', with: user.mail)
click_link_or_button 'Sign In'
- expect(current_url).to eql account_lost_password_url
+ expect(current_url).to eql my_page_url
end
it 'signs in user' do