metova 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGQzZjc2YWI3OGY2MzEwNzA1ZWJlNjUyYjUyNjg4ZmIxNDdmM2I3MA==
4
+ ODNjYWI1M2Y1YjlkYTY1N2E1MTBiN2IxNTE4MjA4NmQwY2MzY2JmNA==
5
5
  data.tar.gz: !binary |-
6
- YmE1OWI2Mzk3YjVlYWQyNmExZWFkOWNmMGI4MjI0MTQwMWY3OTAzNg==
6
+ YzRiMTZjNjA0ZDI5YjdmNmE5NmIwN2UyZjdlN2NkZmNmY2NmNzVhOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjlhODdlZTMwOWVjMDc1MDdjOGQxMjhhZTkzZjYyNzA1ZTdlYWNkYWM1NWVj
10
- ZDQ1ZDNlYWFlNjk2OGZiZjkyNjZhYTM1MWJlMWI1MmMxOWNkYTM4ODEyOGFh
11
- OGVlYTEyOTlhMDA0MGJiMGIxNTc0NGQ1NGVkNTRiOGY3MWFkMmY=
9
+ MTk2ZmNlNTBlMDBmMmEzZTcyNTQ4MTM0MGQ4ZDQwZmM5MTg0MDEwNjkzNTcy
10
+ Mzk2MjdhZGFlN2VmOTAxZDAyZjVhMDQ1M2VlMGQyODIyN2ZkMTAxYzBjYThj
11
+ YjdiZmE0NDA4M2ZiZDAwMWU5NWM5OWVmYTdhOTcxODEwMmNlYzA=
12
12
  data.tar.gz: !binary |-
13
- YjlhZmQ3YjQxZTk0MTlmNzUxODUxODc0Y2U1MDRmMjQzM2I0NGUxODNjZWFh
14
- OThiOGYwNWU2ODUyYTY3ZWEzZTdkNmZjZjAzNjVlNDhkMjRlMDczZTNhOWM0
15
- OWM2ZDVjYTYxOTQzMjgzMmQ1MzQ4Y2ZmYmZhMTY1MjI1ODA1ZjY=
13
+ ZWI1ZDc3Mzk5ZWE4NGNkNmMwMGI2MDU5YmE3NzMyNzk0YTQ1YzdhMzFhMjBj
14
+ YzBiZjRkZmEzZmVhODI2MzhhZjFiM2Q2ZmVjOTg3ZjJiZjE1NmRmZmI3OGNi
15
+ MjBjOWZjYmUyYTBhOTI2OTU5N2RlYzA2OTRhYmQzMjZiYzc5NGU=
@@ -10,14 +10,15 @@ module Devise
10
10
  end
11
11
 
12
12
  def self.required_fields(klass)
13
- [:authentication_token]
13
+ [:authentication_token, :token_expires_at]
14
14
  end
15
15
 
16
16
  def reset_authentication_token
17
17
  self.authentication_token = loop do
18
- token = SecureRandom.hex(20)
18
+ token = Devise.friendly_token
19
19
  break token unless self.class.exists?(authentication_token: token)
20
20
  end
21
+ self.token_expires_at = Time.current + expire_token_in
21
22
  end
22
23
 
23
24
  def reset_authentication_token!
@@ -26,9 +27,16 @@ module Devise
26
27
  end
27
28
 
28
29
  def ensure_authentication_token!
29
- reset_authentication_token! if authentication_token.blank?
30
+ reset_authentication_token! if authentication_token.blank? || token_expired?
30
31
  end
31
32
 
33
+ def token_expired?
34
+ token_expires_at.nil? || token_expires_at.past?
35
+ end
36
+
37
+ def expire_token_in
38
+ 14.days
39
+ end
32
40
  end
33
41
  end
34
42
  end
@@ -20,7 +20,7 @@ module Devise
20
20
  private
21
21
 
22
22
  def valid_token?(user)
23
- Devise.secure_compare user.authentication_token, token
23
+ !user.token_expired? && Devise.secure_compare(user.authentication_token, token)
24
24
  end
25
25
 
26
26
  def token
@@ -1,3 +1,3 @@
1
1
  module Metova
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metova
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Serman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails