1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Coerce time objects serialized as Strings before doing the timeoutable comparisons.

The comparison only fails on Ruby 1.9.3, when we need to parse it properly back
to a Time instance.

Related to #2930.
This commit is contained in:
Lucas Mazza 2014-08-05 14:53:51 -03:00
parent 447b7030f8
commit eb9db7ba3a
3 changed files with 10 additions and 1 deletions

View file

@ -12,6 +12,8 @@ Warden::Manager.after_set_user do |record, warden, options|
if last_request_at.is_a? Integer
last_request_at = Time.at(last_request_at).utc
elsif last_request_at.is_a? String
last_request_at = Time.parse(last_request_at)
end
proxy = Devise::Hooks::Proxy.new(warden)

View file

@ -179,4 +179,11 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
assert_response :success
assert warden.authenticated?(:user)
end
test 'does not crashes when the last_request_at is a String' do
user = sign_in_as_user
get edit_form_user_path(user, last_request_at: Time.now.utc.to_s)
get users_path
end
end

View file

@ -9,7 +9,7 @@ class UsersController < ApplicationController
end
def edit_form
user_session['last_request_at'] = 31.minutes.ago.utc
user_session['last_request_at'] = params.fetch(:last_request_at, 31.minutes.ago.utc)
end
def update_form