Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
af0c08b6
Commit
af0c08b6
authored
Apr 02, 2017
by
mhasbini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix redirection after login when the referer have params
parent
9fc17f6f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
changelogs/unreleased/29669-redirect-referer-params.yml
changelogs/unreleased/29669-redirect-referer-params.yml
+4
-0
spec/controllers/sessions_controller_spec.rb
spec/controllers/sessions_controller_spec.rb
+16
-0
No files found.
app/controllers/sessions_controller.rb
View file @
af0c08b6
...
@@ -79,7 +79,7 @@ class SessionsController < Devise::SessionsController
...
@@ -79,7 +79,7 @@ class SessionsController < Devise::SessionsController
if
request
.
referer
.
present?
&&
(
params
[
'redirect_to_referer'
]
==
'yes'
)
if
request
.
referer
.
present?
&&
(
params
[
'redirect_to_referer'
]
==
'yes'
)
referer_uri
=
URI
(
request
.
referer
)
referer_uri
=
URI
(
request
.
referer
)
if
referer_uri
.
host
==
Gitlab
.
config
.
gitlab
.
host
if
referer_uri
.
host
==
Gitlab
.
config
.
gitlab
.
host
referer_uri
.
path
referer_uri
.
request_uri
else
else
request
.
fullpath
request
.
fullpath
end
end
...
...
changelogs/unreleased/29669-redirect-referer-params.yml
0 → 100644
View file @
af0c08b6
---
title
:
Fix redirection after login when the referer have params
merge_request
:
author
:
mhasbini
spec/controllers/sessions_controller_spec.rb
View file @
af0c08b6
...
@@ -211,4 +211,20 @@ describe SessionsController do
...
@@ -211,4 +211,20 @@ describe SessionsController do
end
end
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment