devise-token_authenticatable 0.4.10 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/README.md +1 -1
- data/devise-token_authenticatable.gemspec +2 -2
- data/lib/devise/token_authenticatable/model.rb +2 -8
- data/lib/devise/token_authenticatable/version.rb +1 -1
- data/spec/factories/admin.rb +1 -1
- data/spec/factories/user.rb +1 -1
- data/spec/models/devise/token_authenticatable/model_spec.rb +6 -30
- data/spec/support/rails_app/app/models/user.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1039c8f938eaa6427775e5d99c572814548eb7e
|
4
|
+
data.tar.gz: ca880f38634ca2474ca156d8ca401a3376b9ade5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4711fd8ffad1960a8009b350da88414c8f165cf786cd5c9f90316f67159df29e9a38390a5c15cea4601be39824bd36f90bc6f21900ca0cb48c849bdbfd13ce28
|
7
|
+
data.tar.gz: b22e38559109eed66592e44edd00a0d9b853790f1059575751e2ba441b9e72e9d23d9b20b76f80a6b43b402ae8ce478eeffa682c48944213992695b51462d40d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,7 @@ Or install it yourself as:
|
|
29
29
|
`~> 0.3` | `~> 3.4.0`
|
30
30
|
`~> 0.4.0`, `< 0.4.9` | `~> 3.5.0`, `< 3.5.2`
|
31
31
|
`~> 0.4.9` | `~> 3.5.2`
|
32
|
+
`~> 0.5.0` | `>= 4.0.0`, `< 4.2.0`
|
32
33
|
|
33
34
|
## Usage
|
34
35
|
|
@@ -47,7 +48,6 @@ This gem can be configured as shown in the following:
|
|
47
48
|
```ruby
|
48
49
|
Devise::TokenAuthenticatable.setup do |config|
|
49
50
|
# enables the expiration of a token after a specified amount of time,
|
50
|
-
# requires an additional field on the model: `authentication_token_created_at`
|
51
51
|
# defaults to nil
|
52
52
|
config.token_expires_in = 1.day
|
53
53
|
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
|
25
|
-
spec.add_dependency "devise", ">=
|
25
|
+
spec.add_dependency "devise", ">= 4.0.0", "< 4.2.0"
|
26
26
|
|
27
|
-
spec.add_development_dependency "rails", "~> 4.
|
27
|
+
spec.add_development_dependency "rails", "~> 4.2"
|
28
28
|
spec.add_development_dependency "rspec-rails", "~> 3.0"
|
29
29
|
spec.add_development_dependency "pry", "~> 0.10"
|
30
30
|
spec.add_development_dependency "factory_girl_rails", "~> 4.4"
|
@@ -53,19 +53,13 @@ module Devise
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.required_fields(klass)
|
56
|
-
|
57
|
-
|
58
|
-
unless Devise::TokenAuthenticatable.token_expires_in.blank?
|
59
|
-
fields.push(:authentication_token_created_at)
|
60
|
-
end
|
61
|
-
|
62
|
-
fields
|
56
|
+
[:authentication_token, :authentication_token_created_at]
|
63
57
|
end
|
64
58
|
|
65
59
|
# Generate new authentication token (a.k.a. "single access token").
|
66
60
|
def reset_authentication_token
|
67
61
|
self.authentication_token = self.class.authentication_token
|
68
|
-
self.authentication_token_created_at = Time.now
|
62
|
+
self.authentication_token_created_at = Time.now
|
69
63
|
end
|
70
64
|
|
71
65
|
# Generate new authentication token and save the record.
|
data/spec/factories/admin.rb
CHANGED
data/spec/factories/user.rb
CHANGED
@@ -18,16 +18,8 @@ shared_examples "token authenticatable" do
|
|
18
18
|
expect { subject }.to change { entity.authentication_token }
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
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
|
21
|
+
it "should reset token created at" do
|
22
|
+
expect { subject }.to change { entity.authentication_token_created_at }
|
31
23
|
end
|
32
24
|
end
|
33
25
|
|
@@ -58,16 +50,8 @@ shared_examples "token authenticatable" do
|
|
58
50
|
expect { subject }.to change { entity.authentication_token }
|
59
51
|
end
|
60
52
|
|
61
|
-
|
62
|
-
|
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
|
53
|
+
it "should set authentication token created at" do
|
54
|
+
expect { subject }.to change { entity.authentication_token_created_at }
|
71
55
|
end
|
72
56
|
end
|
73
57
|
end
|
@@ -105,19 +89,11 @@ shared_examples "token authenticatable" do
|
|
105
89
|
end
|
106
90
|
|
107
91
|
describe "#required_fields" do
|
108
|
-
it "should contain the fields that Devise uses
|
92
|
+
it "should contain the fields that Devise uses" do
|
109
93
|
expect(Devise::Models::TokenAuthenticatable.required_fields(described_class)).to eq([
|
110
|
-
:authentication_token
|
94
|
+
:authentication_token, :authentication_token_created_at
|
111
95
|
])
|
112
96
|
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
|
121
97
|
end
|
122
98
|
|
123
99
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
2
|
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
3
3
|
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
4
|
-
:trackable, :validatable
|
4
|
+
:trackable, :validatable, reconfirmable: false
|
5
5
|
|
6
6
|
attr_accessor :other_key
|
7
7
|
|
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
|
+
version: 0.5.0
|
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-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -16,34 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 4.
|
22
|
+
version: 4.2.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 4.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.
|
32
|
+
version: 4.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rails
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '4.
|
39
|
+
version: '4.2'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '4.
|
46
|
+
version: '4.2'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
211
|
+
rubygems_version: 2.2.2
|
212
212
|
signing_key:
|
213
213
|
specification_version: 4
|
214
214
|
summary: Provides authentication based on an authentication token for devise 3.2 and
|