Commit af0c08b6 authored by mhasbini's avatar mhasbini

Fix redirection after login when the referer have params

parent 9fc17f6f
......@@ -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
......
---
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment