diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 9effc3107..8ff1cb15b 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -36,10 +36,11 @@ class Users::SessionsController < Devise::SessionsController end def expire_in - if current_user.remember_created_at.nil? + if current_user.remember_created_at.nil? || (current_user.remember_created_at + Devise.remember_for).past? render plain: (Devise.timeout_in.to_i - (Time.now.to_i - user_session['last_request_at']).round) * 1000 else - render plain: (Devise.remember_for - (Time.now.to_i - current_user.remember_created_at.to_i).round) * 1000 + render plain: [(Devise.remember_for - (Time.now.to_i - current_user.remember_created_at.to_i).round) * 1000, + (Devise.timeout_in.to_i - (Time.now.to_i - user_session['last_request_at']).round) * 1000].max end end