mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
don't delete the return to url from session if the requested format is not navigational
closes #2122
This commit is contained in:
parent
ee61d86546
commit
61903b534a
2 changed files with 37 additions and 4 deletions
|
@ -162,8 +162,8 @@ module Devise
|
|||
users.any?
|
||||
end
|
||||
|
||||
# Returns and delete the url stored in the session for the given scope. Useful
|
||||
# for giving redirect backs after sign up:
|
||||
# Returns and delete (if it's navigational format) the url stored in the session for
|
||||
# the given scope. Useful for giving redirect backs after sign up:
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
|
@ -171,7 +171,12 @@ module Devise
|
|||
#
|
||||
def stored_location_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
|
||||
if is_navigational_format?
|
||||
session.delete("#{scope}_return_to")
|
||||
else
|
||||
session["#{scope}_return_to"]
|
||||
end
|
||||
end
|
||||
|
||||
# The scope root url to be used when he's signed in. By default, it first
|
||||
|
|
|
@ -13,6 +13,34 @@ class SessionsControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test "#create delete the url stored in the session if the requested format is navigational" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
request.session["user_return_to"] = 'foo.bar'
|
||||
|
||||
user = create_user
|
||||
user.confirm!
|
||||
post :create, :user => {
|
||||
:email => user.email,
|
||||
:password => user.password
|
||||
}
|
||||
|
||||
assert_nil request.session["user_return_to"]
|
||||
end
|
||||
|
||||
test "#create doesn't delete the url stored in the session if the requested format is not navigational" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
request.session["user_return_to"] = 'foo.bar'
|
||||
|
||||
user = create_user
|
||||
user.confirm!
|
||||
post :create, :format => 'json', :user => {
|
||||
:email => user.email,
|
||||
:password => user.password
|
||||
}
|
||||
|
||||
assert_equal 'foo.bar', request.session["user_return_to"]
|
||||
end
|
||||
|
||||
test "#create doesn't raise exception after Warden authentication fails when TestHelpers included" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
post :create, :user => {
|
||||
|
|
Loading…
Reference in a new issue