devise-token_authenticatable 0.4.9 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33ae1c06a79b20b7e886cdbc7795b776b78fc767
4
- data.tar.gz: 175c959f673397ff325234ac4a23d673d6824f7f
3
+ metadata.gz: 18941e6181185c72c432e867d029915727854a34
4
+ data.tar.gz: 366abb9cb6ae2830ee8c8adee619f075d81ee943
5
5
  SHA512:
6
- metadata.gz: be522497669564ea1abc605303c6df1e76a8cb84daeb9bf6366bdbbce48deb0dc669ec76370bc7c5365b13371974eae14094155e85bab4bb9445f5038eeb4176
7
- data.tar.gz: e9404d5a0f635763fff3159df5e40cdf6cd7c716d9adcc8d8b4b4caee2ee905a68e150ddf40ee1e1d332c41f819ee148ec88240b95dce24cccfa0cfde644c79f
6
+ metadata.gz: 629be88bf004382d800360e5b08a795d318bf36b6f4870cafd51377d8a3ad350af6b08380973d2df9b87b792c1571682d084dcb0fafdf9a489e505e8bb95689f
7
+ data.tar.gz: e798e6b774cbbc0efcc1d1bb75de078f28c3e49a25c471a05d27ecf409d6ec724f60aa70c60cb74deacdd355dca71b265259c1299cf0938308d93ace6d01fb41
data/README.md CHANGED
@@ -47,6 +47,7 @@ This gem can be configured as shown in the following:
47
47
  ```ruby
48
48
  Devise::TokenAuthenticatable.setup do |config|
49
49
  # enables the expiration of a token after a specified amount of time,
50
+ # requires an additional field on the model: `authentication_token_created_at`
50
51
  # defaults to nil
51
52
  config.token_expires_in = 1.day
52
53
 
@@ -53,13 +53,19 @@ module Devise
53
53
  end
54
54
 
55
55
  def self.required_fields(klass)
56
- [:authentication_token, :authentication_token_created_at]
56
+ fields = [:authentication_token]
57
+
58
+ unless Devise::TokenAuthenticatable.token_expires_in.blank?
59
+ fields.push(:authentication_token_created_at)
60
+ end
61
+
62
+ fields
57
63
  end
58
64
 
59
65
  # Generate new authentication token (a.k.a. "single access token").
60
66
  def reset_authentication_token
61
67
  self.authentication_token = self.class.authentication_token
62
- self.authentication_token_created_at = Time.now
68
+ self.authentication_token_created_at = Time.now unless token_expires_in.blank?
63
69
  end
64
70
 
65
71
  # Generate new authentication token and save the record.
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module TokenAuthenticatable
3
- VERSION = '0.4.9'.freeze
3
+ VERSION = '0.4.10'.freeze
4
4
  end
5
5
  end
@@ -18,8 +18,16 @@ shared_examples "token authenticatable" do
18
18
  expect { subject }.to change { entity.authentication_token }
19
19
  end
20
20
 
21
- it "should reset token created at" do
22
- expect { subject }.to change { entity.authentication_token_created_at }
21
+ context "token created at" do
22
+ it "should reset" do
23
+ swap Devise::TokenAuthenticatable, token_expires_in: 1.hour do
24
+ expect { subject }.to change { entity.authentication_token_created_at }
25
+ end
26
+ end
27
+
28
+ it "should not reset when token expires in not set" do
29
+ expect { subject }.to_not change { entity.authentication_token_created_at }
30
+ end
23
31
  end
24
32
  end
25
33
 
@@ -50,8 +58,16 @@ shared_examples "token authenticatable" do
50
58
  expect { subject }.to change { entity.authentication_token }
51
59
  end
52
60
 
53
- it "should set authentication token created at" do
54
- expect { subject }.to change { entity.authentication_token_created_at }
61
+ context "token created at" do
62
+ it "should set" do
63
+ swap Devise::TokenAuthenticatable, token_expires_in: 1.hour do
64
+ expect { subject }.to change { entity.authentication_token_created_at }
65
+ end
66
+ end
67
+
68
+ it "should not set when token expires in disabled" do
69
+ expect { subject }.to_not change { entity.authentication_token_created_at }
70
+ end
55
71
  end
56
72
  end
57
73
  end
@@ -89,11 +105,19 @@ shared_examples "token authenticatable" do
89
105
  end
90
106
 
91
107
  describe "#required_fields" do
92
- it "should contain the fields that Devise uses" do
108
+ it "should contain the fields that Devise uses when token expires in disabled" do
93
109
  expect(Devise::Models::TokenAuthenticatable.required_fields(described_class)).to eq([
94
- :authentication_token, :authentication_token_created_at
110
+ :authentication_token
95
111
  ])
96
112
  end
113
+
114
+ it "should contain the fields that Devise uses" do
115
+ swap Devise::TokenAuthenticatable, token_expires_in: 1.hour do
116
+ expect(Devise::Models::TokenAuthenticatable.required_fields(described_class)).to eq([
117
+ :authentication_token, :authentication_token_created_at
118
+ ])
119
+ end
120
+ end
97
121
  end
98
122
 
99
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-token_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Oelke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.2.2
211
+ rubygems_version: 2.4.5.1
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Provides authentication based on an authentication token for devise 3.2 and