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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39eca33e41c3b1d18fb5e49d47729a07cb5a8f28
4
- data.tar.gz: 33275ac7f223777d70718d95c55347f0905f235f
3
+ metadata.gz: 4f2873d50e1638fdb74d85b184b8ad2c8de7e313
4
+ data.tar.gz: e2ea6c097c9c17d009db9dd395efdae7908abd90
5
5
  SHA512:
6
- metadata.gz: 308debaddd2df7be32a45bd0788522878579ca80f229533bc3c362a800590dd1add53f71916b0bbf9eaae6585b35ebd222527e0a077555a5dc84f5a7d8845885
7
- data.tar.gz: f92668a1d726bca77a101a3370e2b8fe5a0dcfa0c98c3469535994b9b85eea718a46bfb8ccb530a005f9b7e0f94d28149c5dcc560e686a662184ac12e064dee0
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
- many_to_one :user
9
- one_to_many :auth_tokens
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
- add_auth_token user: user, last_used_at: Time.now.utc
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
- plugin :timestamps
8
+ if respond_to? :belongs_to
9
+ belongs_to :auth_method
10
+ belongs_to :user
11
+ else
12
+ plugin :timestamps
9
13
 
10
- many_to_one :auth_method
11
- many_to_one :user
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
- self.update(closed_at: Time.now) unless self.closed_at
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
- auth_token.update(last_used_at: Time.now)
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
@@ -7,8 +7,13 @@ module Jm81auth
7
7
  base.extend ClassMethods
8
8
 
9
9
  base.class_eval do
10
- one_to_many :auth_methods
11
- one_to_many :auth_tokens
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
 
@@ -1,3 +1,3 @@
1
1
  module Jm81auth
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
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.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: 2017-04-06 00:00:00.000000000 Z
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.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/factories/users.rb
164
- - spec/factories/auth_tokens.rb
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