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

34 lines
931 B
Ruby
Raw Normal View History

require 'devise/hooks/timeoutable'
module Devise
module Models
2009-11-22 23:29:03 -02:00
# Timeoutable takes care of veryfing whether a user session has already
# expired or not. When a session expires after the configured time, the user
# will be asked for credentials again, it means, he/she will be redirected
# to the sign in page.
#
2010-07-15 13:01:31 +02:00
# == Options
#
# Timeoutable adds the following options to devise_for:
#
# * +timeout_in+: the interval to timeout the user session without activity.
#
# == Examples
#
# user.timedout?(30.minutes.ago)
2009-11-22 23:29:03 -02:00
#
module Timeoutable
2010-02-17 12:35:38 +01:00
extend ActiveSupport::Concern
# Checks whether the user session has expired based on configured time.
2010-01-14 15:47:14 +01:00
def timedout?(last_access)
last_access && last_access <= self.class.timeout_in.ago
end
module ClassMethods
Devise::Models.config(self, :timeout_in)
end
end
end
end