Detect when a devise session expires

后端 未结 2 405
北恋
北恋 2021-01-13 14:52

I\'d like to record when a user\'s session has timed out, using devise and :timeoutable.

At the moment, :timeoutable is working as expected

2条回答
  •  死守一世寂寞
    2021-01-13 15:03

    i've not seen any kind of hook, but you could just override the code in the timeoutable module that is used by devise:

    module Devise
      module Models
        module Timeoutable
          def timedout?(last_access)
            #  your custom code goes into this method
            return false if remember_exists_and_not_expired?
            !timeout_in.nil? && last_access && last_access <= timeout_in.ago
          end
        end
      end
    end
    

提交回复
热议问题