valid period depend on trusted_device_token.created_at

This commit is contained in:
simon lehericey 2019-02-04 11:57:50 +01:00
parent d664f130fd
commit 7de3a18fd1
3 changed files with 10 additions and 8 deletions

View file

@ -4,10 +4,10 @@ module TrustedDeviceConcern
TRUSTED_DEVICE_COOKIE_NAME = :trusted_device
TRUSTED_DEVICE_PERIOD = 1.month
def trust_device
def trust_device(start_at)
cookies.encrypted[TRUSTED_DEVICE_COOKIE_NAME] = {
value: JSON.generate({ created_at: Time.zone.now }),
expires: TRUSTED_DEVICE_PERIOD,
value: JSON.generate({ created_at: start_at }),
expires: start_at + TRUSTED_DEVICE_PERIOD,
httponly: true
}
end