Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Timeoutable timeouts flash hash keys #4464

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/devise/failure_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def recall
def redirect
store_location!
if is_flashing_format?
if flash[:timedout] && flash[:alert]
flash.keep(:timedout)
if flash[:alert]
flash.keep(:alert)
else
flash[:alert] = i18n_message
Expand Down Expand Up @@ -113,7 +112,6 @@ def i18n_message(default = nil)

def redirect_url
if warden_message == :timeout
flash[:timedout] = true if is_flashing_format?

path = if request.get?
attempted_path
Expand Down
7 changes: 7 additions & 0 deletions test/failure_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ def call_failure(env_params={})
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end

test 'does not set timedout key on flash hash' do
call_failure('warden' => OpenStruct.new(message: :timeout))
assert_nil @request.flash[:timedout]
assert_equal 'Your session expired. Please sign in again to continue.', @request.flash[:alert]
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end

test 'supports authentication_keys as a Hash for the flash message' do
swap Devise, authentication_keys: { email: true, login: true } do
call_failure('warden' => OpenStruct.new(message: :invalid))
Expand Down