devise-token_authenticatable icon indicating copy to clipboard operation
devise-token_authenticatable copied to clipboard

Expiration not working

Open prcongithub opened this issue 2 years ago • 2 comments

https://github.com/baschtl/devise-token_authenticatable/blob/2e9e3e9ed59916715a019ae3fd9399bba9c1b3e6/lib/devise/token_authenticatable/strategy.rb#L40

Devise::TokenAuthenticatable.setup do |config|
  config.token_expires_in = 90.days
end
irb(main):019:0> resource = User.last
=> #<User _id: BSON::ObjectId('63906c700f1a26001eae45dd'), access_tokens: ["qoUUnr0aeSX1Pc8gE6TD1VQ8w6V3RJBf"], activated_at: Wed, 07 Dec 2022 10:35:28 +0000, ac...
irb(main):020:0> resource.authentication_token_created_at = Time.now-100.days
=> 2022-11-12 06:18:34.494768917 +0000
irb(main):021:0> resource.save!
=> true
irb(main):022:0> resource.token_expires_in
=> 90 days
irb(main):023:0> resource.authentication_token_created_at
=> Sat, 12 Nov 2022 06:18:34 +0000
irb(main):024:0> Time.now > (resource.authentication_token_created_at + resource.token_expires_in.to_i)
=> false
irb(main):025:0> Time.now
=> 2023-02-20 06:19:16.49710795 +0000
irb(main):026:0> Time.now > (resource.authentication_token_created_at + resource.token_expires_in)
=> true
irb(main):027:0>

Am I missing something?

Version: 1.1.0

prcongithub avatar Feb 20 '23 06:02 prcongithub

#58 https://github.com/baschtl/devise-token_authenticatable/pull/58

prcongithub avatar Feb 24 '23 06:02 prcongithub

@prcongithub I did not follow changes in Ruby or Devise for a long time. Is this a change that happened in devise? Can you explain why this worked before? Which devise versions is this compatible with?

baschtl avatar Jun 26 '24 03:06 baschtl