Trusted_device: cleaner time comparison
This commit is contained in:
parent
b2e4d95580
commit
41ae1f46f4
1 changed files with 5 additions and 1 deletions
|
@ -14,11 +14,15 @@ module TrustedDeviceConcern
|
||||||
|
|
||||||
def trusted_device?
|
def trusted_device?
|
||||||
trusted_device_cookie.present? &&
|
trusted_device_cookie.present? &&
|
||||||
Time.zone.now - TRUSTED_DEVICE_PERIOD < JSON.parse(trusted_device_cookie)['created_at']
|
(Time.zone.now - TRUSTED_DEVICE_PERIOD) < trusted_device_cookie_created_at
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def trusted_device_cookie_created_at
|
||||||
|
Time.zone.parse(JSON.parse(trusted_device_cookie)['created_at'])
|
||||||
|
end
|
||||||
|
|
||||||
def trusted_device_cookie
|
def trusted_device_cookie
|
||||||
cookies.encrypted[TRUSTED_DEVICE_COOKIE_NAME]
|
cookies.encrypted[TRUSTED_DEVICE_COOKIE_NAME]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue