cow_auth 0.4.1 → 0.4.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: 8a04da1623077325b6fcfd473d24756eba41cac3
4
- data.tar.gz: dae5348ed8065a6632bcb727369163139c384276
3
+ metadata.gz: dff8fe9127d7933119a7bc9e1a394b63459347b8
4
+ data.tar.gz: 044fe42d8ab52301dcb26d555b2249a2e361469b
5
5
  SHA512:
6
- metadata.gz: '0872f0f79362209f6ad2b9e47be1ef98342326629751751b3a430ea2a6588feae1e30ce5748ce2686688d37babfeb27f711ff8f32a44e8559a9fcb9e1faa4842'
7
- data.tar.gz: 63459f76b4abeb7114a37c5885a66d9351769ac61071a7ebc304adb1fc6512ebf6a065c6934b158048047226640d7f48a9a01ce84f8cc276601ad0e0c596662f
6
+ metadata.gz: 6470c86664faba0fa3e5900666cb3222a91b2516331809d642f3c6398317ed5a9814be3e8eab0aadb188a0387ff7254ca81f3757bc58566e5af834d384f44a75
7
+ data.tar.gz: ce090243601ce2a58903a1881419837be92c0edb65b6681f5459c900c7baf7823d66d3eb118ed877d35b705712090898b3d58483c9617533ebcce5c06fb629f8
data/lib/cow_auth/user.rb CHANGED
@@ -30,7 +30,7 @@ module CowAuth
30
30
  def api_sign_in
31
31
  User.assert_redis_handle_present
32
32
  $redis.set(self.redis_key, {
33
- auth_token: User.generate_auth_token,
33
+ auth_token: self.token_valid? ? self.auth_token : User.generate_auth_token,
34
34
  expires_at: User.generate_token_expires_at
35
35
  }.to_json)
36
36
  end
@@ -62,6 +62,14 @@ module CowAuth
62
62
  return "user_#{self.sid}"
63
63
  end
64
64
 
65
+ def token_valid?
66
+ api_key = User.fetch_api_key_from_redis(self.sid)
67
+ return api_key.present? &&
68
+ api_key.key?(:auth_token) &&
69
+ api_key.key?(:expires_at) &&
70
+ api_key[:expires_at] > Time.zone.now
71
+ end
72
+
65
73
  private
66
74
 
67
75
  def generate_sid_if_necessary
@@ -1,3 +1,3 @@
1
1
  module CowAuth
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cow_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickey Cowden
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-29 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.6.11
130
+ rubygems_version: 2.6.12
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Authentication gem