1
0
Fork 0

Do not timeout if remembered

This commit is contained in:
Alex Kotov 2019-09-05 02:38:59 +05:00
parent fdcb703bec
commit 8be0d1334d
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -36,4 +36,25 @@ class User < ApplicationRecord
before_validation do
self.account ||= Account.new
end
###########
# Methods #
###########
def remember_exists_and_not_expired?
return false unless respond_to? :remember_created_at
return false unless respond_to? :remember_expired?
remember_created_at && !remember_expired?
end
def remember_expired?
remember_created_at.nil? || (remember_expires_at <= Time.now.utc)
end
def timedout?(last_access)
return false if remember_exists_and_not_expired?
!timeout_in.nil? && last_access && last_access <= timeout_in.ago
end
end