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

Do not set a back_url when logging in through omniauth

Oliver Günther20ccad0991c7
diff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rb
index 1e72b3427e0..05219a5c314 100644
--- a/app/controllers/concerns/accounts/omniauth_login.rb
+++ b/app/controllers/concerns/accounts/omniauth_login.rb
@@ -47,9 +47,6 @@ module Accounts::OmniauthLogin
end
def omniauth_login
- # Set back url to page the omniauth login link was clicked on
- params[:back_url] = request.env['omniauth.origin']
-
# Extract auth info and perform check / login or activate user
auth_hash = request.env['omniauth.auth']
handle_omniauth_authentication(auth_hash)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7cdaf798e0d..19a349c2819 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -305,8 +305,8 @@ module ApplicationHelper
form_for(record, options, &)
end
- def back_url_hidden_field_tag
- back_url = params[:back_url] || request.env['HTTP_REFERER']
+ def back_url_hidden_field_tag(use_referer: true)
+ back_url = params[:back_url] || (use_referer ? request.env['HTTP_REFERER'] : nil)
back_url = CGI.unescape(back_url.to_s)
hidden_field_tag('back_url', CGI.escape(back_url), id: nil) if back_url.present?
end
diff --git a/app/views/account/_register.html.erb b/app/views/account/_register.html.erb
index fa5fdd197fb..50a79ae40bb 100644
--- a/app/views/account/_register.html.erb
+++ b/app/views/account/_register.html.erb
@@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="modal-delivery-element">
<%= labelled_tabular_form_for(@user, url: account_register_path, html: { class: 'form -wide-labels spot-modal' }) do |f| %>
- <%= back_url_hidden_field_tag %>
+ <%= back_url_hidden_field_tag use_referer: false %>
<%= error_messages_for :user %>
<div id="spotModalTitle" class="spot-modal--header">
diff --git a/spec/features/users/invitation_spec.rb b/spec/features/users/invitation_spec.rb
index d5b8a4969d8..d2aa331ce4b 100644
--- a/spec/features/users/invitation_spec.rb
+++ b/spec/features/users/invitation_spec.rb
@@ -31,19 +31,17 @@ require 'spec_helper'
RSpec.describe 'invitations', :js, :with_cuprite do
let(:user) { create(:invited_user, mail: '[email protected]') }
- before do
- allow(User).to receive(:current).and_return current_user
- end
-
shared_examples 'resending invitations' do |redirect_to_edit_page: true|
it 'resends the invitation' do
+ login_with current_user.login, 'adminADMIN!'
+
visit user_path(user)
click_on I18n.t(:label_send_invitation)
expect(page).to have_text 'An invitation has been sent to [email protected].'
expect(page).to have_current_path redirect_to_edit_page ? edit_user_path(user) : user_path(user)
# Logout admin
- logout
+ visit signout_path
# Visit invitation with wrong token
visit account_activate_path(token: 'some invalid value')