Fix redirection after login when the referer have params
This commit is contained in:
parent
9fc17f6f4a
commit
af0c08b6f9
3 changed files with 21 additions and 1 deletions
|
@ -79,7 +79,7 @@ class SessionsController < Devise::SessionsController
|
|||
if request.referer.present? && (params['redirect_to_referer'] == 'yes')
|
||||
referer_uri = URI(request.referer)
|
||||
if referer_uri.host == Gitlab.config.gitlab.host
|
||||
referer_uri.path
|
||||
referer_uri.request_uri
|
||||
else
|
||||
request.fullpath
|
||||
end
|
||||
|
|
4
changelogs/unreleased/29669-redirect-referer-params.yml
Normal file
4
changelogs/unreleased/29669-redirect-referer-params.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix redirection after login when the referer have params
|
||||
merge_request:
|
||||
author: mhasbini
|
|
@ -211,4 +211,20 @@ describe SessionsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#new' do
|
||||
before do
|
||||
@request.env['devise.mapping'] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
it 'redirects correctly for referer on same host with params' do
|
||||
search_path = '/search?search=seed_project'
|
||||
allow(controller.request).to receive(:referer).
|
||||
and_return('http://%{host}%{path}' % { host: Gitlab.config.gitlab.host, path: search_path })
|
||||
|
||||
get(:new, redirect_to_referer: :yes)
|
||||
|
||||
expect(controller.stored_location_for(:redirect)).to eq(search_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue