Module: Devise::Models::Timeoutable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/devise/models/timeoutable.rb
Overview
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.
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)
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#timedout?(last_access) ⇒ Boolean
Checks whether the user session has expired based on configured time.
- #timeout_in ⇒ Object
Class Method Details
.required_fields(klass) ⇒ Object
23 24 25 |
# File 'lib/devise/models/timeoutable.rb', line 23 def self.required_fields(klass) [] end |
Instance Method Details
#timedout?(last_access) ⇒ Boolean
Checks whether the user session has expired based on configured time.
28 29 30 31 |
# File 'lib/devise/models/timeoutable.rb', line 28 def timedout?(last_access) return false if remember_exists_and_not_expired? !timeout_in.nil? && last_access && last_access <= timeout_in.ago end |
#timeout_in ⇒ Object
33 34 35 |
# File 'lib/devise/models/timeoutable.rb', line 33 def timeout_in self.class.timeout_in end |