jm81auth 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jm81auth/models/auth_method.rb +12 -3
- data/lib/jm81auth/models/auth_token.rb +20 -5
- data/lib/jm81auth/models/user.rb +7 -2
- data/lib/jm81auth/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f2873d50e1638fdb74d85b184b8ad2c8de7e313
|
4
|
+
data.tar.gz: e2ea6c097c9c17d009db9dd395efdae7908abd90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d39f490120b1bb4cf67bef639c3e3fe2d1fb1e73e858522513b52b563df5e5741392b300d277cc57aa4a7d97a081b14f3a0ca165fe01cffe7eb4aef2be09c396
|
7
|
+
data.tar.gz: '09ebd943d1bc77b9c5f5504eb32bff049431bc4bc709c9fa18f3bfe2a6f719fb63cc860574b2432249e9d8e401b0ce764456d0cf11b96c419a75dcbb207b4889'
|
@@ -5,8 +5,13 @@ module Jm81auth
|
|
5
5
|
base.extend ClassMethods
|
6
6
|
|
7
7
|
base.class_eval do
|
8
|
-
|
9
|
-
|
8
|
+
if respond_to? :belongs_to
|
9
|
+
belongs_to :user
|
10
|
+
has_many :auth_tokens
|
11
|
+
else
|
12
|
+
many_to_one :user
|
13
|
+
one_to_many :auth_tokens
|
14
|
+
end
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
@@ -14,7 +19,11 @@ module Jm81auth
|
|
14
19
|
#
|
15
20
|
# @return [AuthToken]
|
16
21
|
def create_token
|
17
|
-
|
22
|
+
if respond_to? :belongs_to
|
23
|
+
auth_tokens.create! user: user, last_used_at: Time.now.utc
|
24
|
+
else
|
25
|
+
add_auth_token user: user, last_used_at: Time.now.utc
|
26
|
+
end
|
18
27
|
end
|
19
28
|
|
20
29
|
module ClassMethods
|
@@ -5,10 +5,15 @@ module Jm81auth
|
|
5
5
|
base.extend ClassMethods
|
6
6
|
|
7
7
|
base.class_eval do
|
8
|
-
|
8
|
+
if respond_to? :belongs_to
|
9
|
+
belongs_to :auth_method
|
10
|
+
belongs_to :user
|
11
|
+
else
|
12
|
+
plugin :timestamps
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
many_to_one :auth_method
|
15
|
+
many_to_one :user
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
@@ -17,7 +22,13 @@ module Jm81auth
|
|
17
22
|
|
18
23
|
# Set #closed_at. Called, for example, when logging out.
|
19
24
|
def close!
|
20
|
-
|
25
|
+
unless self.closed_at
|
26
|
+
if respond_to? :update_attributes!
|
27
|
+
self.update_attributes! closed_at: Time.now
|
28
|
+
else
|
29
|
+
self.update closed_at: Time.now
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
34
|
# @return [String]
|
@@ -84,7 +95,11 @@ module Jm81auth
|
|
84
95
|
auth_token = decode token
|
85
96
|
|
86
97
|
if auth_token && !auth_token.expired?
|
87
|
-
|
98
|
+
if respond_to? :update_attributes!
|
99
|
+
auth_token.update_attributes! last_used_at: Time.now
|
100
|
+
else
|
101
|
+
auth_token.update last_used_at: Time.now
|
102
|
+
end
|
88
103
|
auth_token
|
89
104
|
else
|
90
105
|
nil
|
data/lib/jm81auth/models/user.rb
CHANGED
@@ -7,8 +7,13 @@ module Jm81auth
|
|
7
7
|
base.extend ClassMethods
|
8
8
|
|
9
9
|
base.class_eval do
|
10
|
-
|
11
|
-
|
10
|
+
if respond_to? :has_many
|
11
|
+
has_many :auth_methods
|
12
|
+
has_many :auth_tokens
|
13
|
+
else
|
14
|
+
one_to_many :auth_methods
|
15
|
+
one_to_many :auth_tokens
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
data/lib/jm81auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jm81auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -155,16 +155,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.2.
|
158
|
+
rubygems_version: 2.5.2.3
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: An authentication library for Rails API
|
162
162
|
test_files:
|
163
|
-
- spec/
|
164
|
-
- spec/
|
165
|
-
- spec/factories/auth_methods.rb
|
163
|
+
- spec/jm81auth/oauth/base_spec.rb
|
164
|
+
- spec/jm81auth/models/auth_method_spec.rb
|
166
165
|
- spec/jm81auth/models/auth_token_spec.rb
|
167
166
|
- spec/jm81auth/models/user_spec.rb
|
168
|
-
- spec/jm81auth/models/auth_method_spec.rb
|
169
|
-
- spec/jm81auth/oauth/base_spec.rb
|
170
167
|
- spec/spec_helper.rb
|
168
|
+
- spec/factories/auth_methods.rb
|
169
|
+
- spec/factories/auth_tokens.rb
|
170
|
+
- spec/factories/users.rb
|